On Nov 6, 5:28 am, [EMAIL PROTECTED] (Sivasakthi) wrote: > How to get the line before a last line from file??
Here's a few off the top of my head. I'm sure there's more. #1 open my $fh, '<', $file or die $!; my $before_last = (<$fh>)[-2]; #2 open my $fh, '<', $file or die $!; my ($last, $before_last); while (<$fh>) { $before_last = $last; $last = $_; } #3 use File::ReadBackwards; my $bw = File::ReadBackwards->new($file) or die $! $bw->readline(); my $before_last = $bw->readline(); Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/