in reply to how can i read only the last line of a files
This will work with huge files, where you don't want to store the whole file in memory, although, by the extensions, I'm guessing your files are fairly short. Also, for huge files, you almost certainly want File::ReadBackwards as davorg has already suggested.my $last_line; for my $fname ( 'tax.pl', 'accno.pl', 'ptax.pl' ) { open INFILE, $fname; while (<INFILE>) { chomp; $last_line = $_; } close INFILE; print "$fname:$last_line\n"; $last_line = ''; # in case 2nd or 3rd file is empty }
|
|---|