<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Substitution for tail -1 in a Perl script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/substitution-for-tail-1-in-a-perl-script/m-p/3636300#M808224</link>
    <description>Hi Stephen:&lt;BR /&gt;&lt;BR /&gt;Onw way to accomplish this is to add a test for end-of-file like this:&lt;BR /&gt;&lt;BR /&gt;while (&lt;INP&gt;) {&lt;BR /&gt;    next if !eof;  &lt;BR /&gt;    chomp;&lt;BR /&gt;    ...&lt;BR /&gt;&lt;BR /&gt;This would process *only* the last line.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/INP&gt;</description>
    <pubDate>Tue, 27 Sep 2005 13:59:05 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2005-09-27T13:59:05Z</dc:date>
    <item>
      <title>Substitution for tail -1 in a Perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/substitution-for-tail-1-in-a-perl-script/m-p/3636299#M808223</link>
      <description>I m writing this script and I 've encountered &lt;BR /&gt;a problem in substititing tail -1 in a Perl script to get the last line in a file. SOS please.&lt;BR /&gt;&lt;BR /&gt;My script is as follows:&lt;BR /&gt;&lt;BR /&gt;#!/usr/local/bin/perl&lt;BR /&gt;open(INP,"/export/home/soglesby/gents_processed");&lt;BR /&gt;while(&lt;INP&gt;) {&lt;BR /&gt;chomp;&lt;BR /&gt;next unless /dat/;&lt;BR /&gt;@a=split('\s+',$_);&lt;BR /&gt;$a[8]=~s/\.dat//g;&lt;BR /&gt;$a[8]=~s/return_//g;&lt;BR /&gt;#system "tail -1" I've tried this&lt;BR /&gt;print &lt;BR /&gt;print "\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;/INP&gt;</description>
      <pubDate>Tue, 27 Sep 2005 13:49:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/substitution-for-tail-1-in-a-perl-script/m-p/3636299#M808223</guid>
      <dc:creator>Stephen_175</dc:creator>
      <dc:date>2005-09-27T13:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: Substitution for tail -1 in a Perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/substitution-for-tail-1-in-a-perl-script/m-p/3636300#M808224</link>
      <description>Hi Stephen:&lt;BR /&gt;&lt;BR /&gt;Onw way to accomplish this is to add a test for end-of-file like this:&lt;BR /&gt;&lt;BR /&gt;while (&lt;INP&gt;) {&lt;BR /&gt;    next if !eof;  &lt;BR /&gt;    chomp;&lt;BR /&gt;    ...&lt;BR /&gt;&lt;BR /&gt;This would process *only* the last line.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/INP&gt;</description>
      <pubDate>Tue, 27 Sep 2005 13:59:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/substitution-for-tail-1-in-a-perl-script/m-p/3636300#M808224</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-09-27T13:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: Substitution for tail -1 in a Perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/substitution-for-tail-1-in-a-perl-script/m-p/3636301#M808225</link>
      <description>Thanks, sounds like a great idea!</description>
      <pubDate>Tue, 27 Sep 2005 14:04:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/substitution-for-tail-1-in-a-perl-script/m-p/3636301#M808225</guid>
      <dc:creator>Stephen_175</dc:creator>
      <dc:date>2005-09-27T14:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Substitution for tail -1 in a Perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/substitution-for-tail-1-in-a-perl-script/m-p/3636302#M808226</link>
      <description>One linear as,&lt;BR /&gt;&lt;BR /&gt;# perl -ne 'print if eof' &lt;FILENAME&gt;&lt;BR /&gt;&lt;BR /&gt;hth.&lt;/FILENAME&gt;</description>
      <pubDate>Wed, 28 Sep 2005 00:32:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/substitution-for-tail-1-in-a-perl-script/m-p/3636302#M808226</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-28T00:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Substitution for tail -1 in a Perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/substitution-for-tail-1-in-a-perl-script/m-p/3636303#M808227</link>
      <description>#!/usr/bin/perl -w&lt;BR /&gt;# example for files with max line lengths &amp;lt; 400, but it's adjustable &lt;BR /&gt;# usage tailz  filename  numberoflines &lt;BR /&gt;use strict;&lt;BR /&gt;&lt;BR /&gt;die "Usage: $0 file numlines\n" unless @ARGV == 2;&lt;BR /&gt;my ($filename, $numlines) = @ARGV;&lt;BR /&gt;&lt;BR /&gt;my $chunk = 400 * $numlines; #assume a &amp;lt;= 400 char line(generous) &lt;BR /&gt;&lt;BR /&gt;# Open the file in read mode &lt;BR /&gt;open FILE, "&amp;lt;$filename" or die "Couldn't open $filename: $!";&lt;BR /&gt;my $filesize = -s FILE;&lt;BR /&gt;if($chunk &amp;gt;= $filesize){$chunk = $filesize}&lt;BR /&gt;seek FILE,-$chunk,2; #get last chunk of bytes &lt;BR /&gt;&lt;BR /&gt;my @tail = &lt;FILE&gt;;&lt;BR /&gt;if($numlines &amp;gt;= $#tail +1){$numlines = $#tail +1}&lt;BR /&gt;splice @tail, 0, @tail - $numlines;&lt;BR /&gt;&lt;BR /&gt;print "@tail\n";&lt;BR /&gt;exit;&lt;BR /&gt;&lt;BR /&gt;=============================&lt;BR /&gt;&lt;BR /&gt;# ./tailz.pl&lt;BR /&gt;Usage: ./tailz.pl file numlines&lt;BR /&gt;&lt;BR /&gt;-Arun&lt;/FILE&gt;</description>
      <pubDate>Wed, 28 Sep 2005 00:48:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/substitution-for-tail-1-in-a-perl-script/m-p/3636303#M808227</guid>
      <dc:creator>Arunvijai_4</dc:creator>
      <dc:date>2005-09-28T00:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Substitution for tail -1 in a Perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/substitution-for-tail-1-in-a-perl-script/m-p/3636304#M808228</link>
      <description>chomp (my $last_line = (&lt;INP&gt;)[-1]);&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn&lt;/INP&gt;</description>
      <pubDate>Wed, 28 Sep 2005 01:28:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/substitution-for-tail-1-in-a-perl-script/m-p/3636304#M808228</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2005-09-28T01:28:07Z</dc:date>
    </item>
  </channel>
</rss>

