in reply to Re^2: removing comments
in thread removing comments

You'd have to open an input and an output file — generally they're not the same one, unless you're very clever about it.

There is actually an example on the page I linked but it may have been unobvious to locate.

open my $input, "<", $ARGV[0] or die "couldn't open $ARGV[0]: $!"; open my $output, ">", "output.txt" or die "coudln't open output: $!"; while(<$input>) { if( m/something/ ) { # do stuff } s/stuff//g; # etc. print {$output} $_; } close $output; close $input;

-Paul