But if the last line of the file ends not with newline, second regex do not match and don't delete anything.
That can easily be fixed by changing the regex object definition
my $line_regex = qr/[^\n]*\n/;
to
my $line_regex = qr/[^\n]*\n?/;
(note final \n has ? quantifier added). (Tested.)
But you need to go one step further in the example: show extraction of each remaining line for further processing.
Update: And see also File::Slurp.
Give a man a fish: <%-{-{-{-<
In reply to Re^3: More efficient way to exclude footers
by AnomalousMonk
in thread More efficient way to exclude footers
by babysFirstPerl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |