use strict; use warnings; use Tie::File; # usage: perl script.pl [file1] [file2] [...] foreach my $file (grep { -f } @ARGV) { tie my @file, 'Tie::File', $file or die "Can't tie into file $file: $!"; my $regex = qr/\sSIL\s*\z/; foreach my $i (reverse 0 .. $#file) { if ($file[$i] =~ /$regex/) { 1 while ($file[--$i] =~ /$regex/); print "$file[$i + 1]\n"; $#file = $i + 1; last; } } untie @file; }
In reply to Re: removing lines that are in the end of a file
by trizen
in thread removing lines that are in the end of a file
by bhargavkanakiya
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |