in reply to Re: Modifying 'next' in foreach loop
in thread Modifying 'next' in foreach loop

for( my $i = 0; $i <= $#lines; $i++ ) {

would be better written:

for my $i (0 .. $#lines) {

Perl is environmentally friendly - it saves trees