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

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



Excerpt of message (sent 29 January 1999) by Stˇphane Jose:
> I don't know how to simulate the call to 'tail'
> Since the log could be very large I'd like to avoid reading the
> whole file into memory...

> open (ALOG, "tail -1  $access_log | tail -1 |") || die $!;
> $line = <ALOG>;
> close (ALOG);

The following won't load it all into memory, but reads the whole file

    open ALOG, $access_log or die $!;
    while (<ALOG>) {$line = $_;}
    close (ALOG);

It won't bloat your memory, but may take long.  A more sophisticated
approach would be to seek to the end and search from there backwards
till you hit a '\n'.

	Christian Brechbuehler
	
	Communication Technology Laboratory, Image Science Group
	Swiss Federal Institute of Technology (ETH), Zurich

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