" #!perl -i.bak @ARGV = ($0); while (<>) { $end = 1 if /^__END__/; print if $end < 2; $end++ if /^"/ and $end; if (eof) { open my $f, "; # manipulate the line here close $f; } } __END__ " # normal lines start here # etc. etc.