in reply to How can I grab the last 2 lines of a file?
Take a look at File::ReadBackwards:
#!/usr/bin/perl use strict; use warnings; use feature qw/say/; use File::ReadBackwards; tie *BW, 'File::ReadBackwards', '/path/to/your_file' or die "Cannot re +ad file: $!"; chomp(my $name = <BW>); chomp(my $id = <BW>); say "Name: $name"; say "ID: $id";
Hope this helps!
|
|---|