Alex Chen wrote: > hi, all > > i want to know how to get the last line of > a file .i know the func read has a paramenter offset but i don't know how > to use it.please help!!! > > thanks > alex chen
try this: #!/usr/bin/perl -w; use strict; my $line=''; my $byte=''; open(FH,"foo.txt") || die $!; seek(FH,(-s "foo.txt")-2,0); while(1){ read(FH,$byte,1); print $line and last if($byte eq "\n"); $line = $byte . $line; seek(FH,tell(FH)-2,0); } close(FH); __END__ david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]