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

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



=?iso-8859-1?Q?St=E9phane?= Jose <stephane.jose@sympatico.ca> writes:

>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.

Are you interested in being a test subject for Uri Guttman's Backwards
module?  <URL:http://www.sysarch.com/perl/Backwards.pm>

The basic design of it reads blocks of a file at a time, starting from
the end (with block boundries that would product efficient disk
access) splits the contents of the block on the newline boundry, pops
off the last one to return to you, and saves the rest for the next
call.

Of course, in you example (tail -1) there is no next call, but used to
create a general tail substitute there might be.


-- 
Andrew Langmead

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