[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] How to simulate a call to 'tail' in MacPerl



At 15.22 -0500 1999.01.29, Bart Lateur wrote:
>On Fri, 29 Jan 1999 14:11:14 -0500, Stˇphane Jose wrote:
>
>>I am using the following script to read the last line from a log file.
>>This works fine under Unix but I don't know how to simulate the call to
>>'tail' on a Mac with MacPerl.
>
>Something like this?
>
>while(<FILE>) { }
># now $_ is the last line in the file!

No, that's wrong.  If $_ had a value, the while loop would never end!  :)

But you could do:

  while (<F>) {$l = $_}

And then $l is the last line.  On big files:

  seek F, -100, 2;   # bigger than 100 for potentially long lines in file
  $l = $_ while <F>;
  # $l is last line

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch