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

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



Hi,

Thanks for your comments about my previous message.

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.

Is there a way to adapt the script so it does not have to use an external
program?

The log file is using a variable-length format. Since the log could be very
large I'd like to avoid reading the whole file into memory...

Any suggestions?

################
#! /usr/bin/perl

$access_log = "/files/admin_cd/users.log";

open (ALOG, "tail -1  $access_log | tail -1 |") || die $!;

$line = <ALOG>;

close (ALOG);

print "Last line of log: $line";

exit(0);
###############

Stephane


               ____S__t__e__p__h__a__n__e______J__o__s__e____

                     mailto:stephane.jose@sympatico.ca


                 Don't you ever try to look behind my eyes
                 You might not like what they have seen...

                 Ron L. Hoover - Joe's Garage

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