Hi, Alex i suggest the following:
#!/usr/local/bin/perl -w my $filename = "Your_file_name"; # if you are so lucky to work on Unix my $lastline = `tail -1 $filename`; print $lastline; # if file is small enough to hold in an array open(FILE, $filename) or die "Can't open $filename.\n"; my @array = (<FILE>); close(FILE); $lastline = $array[-1]; print $lastline; # otherwise, read file line by line and retain the last one open(FILE, $filename) or die "Can't open $filename.\n"; while($_ = <FILE>) {$lastline = $_;}; close(FILE); print $lastline; Hope it helps. alex chen a écrit : > > 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 > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED]
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]