Karen Liew Ying Ping wrote:
> 
> Hi,

Hello,

> Let's say I'm opening a file.
> How do I read the last line of the file?
> is there any function in doing so?


use File::ReadBackwards;
my $bw = File::ReadBackwards->new( $file ) or die "Cannot read $file:
$!";
my $last_line = $bw->readline;

# OR

my $last_line = `tail -1 $file`;

# OR

open FILE, $file or die "Cannot read $file: $!";
my $last_line;
$last_line = $_ while <FILE>;



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to