I guess it depends on how exactly you want to emulate the behavior of tail. You could use the seek function in perl to get toward the end of a file (after doing a file size check), the read the file line by line and print out the last line you encounter. This requires, of course, that you decide what the "maximum" size of a log line can be so you can be sure to start at least that far away from the end of the file. Or you could simply read the file line by line, printing out the last line, which may be more failsafe, but could slow way down if your log file is enormous. The seek entry in the blue camel book would probably be a good place to start. John >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 ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch