in reply to Read In A File, Manipulate It, Spit It Back Out
... and ...# version 1 ## problem, does not skip comments undef($/); my $text = <fp>; foreach my $pat (keys %my_replacement) { $text =~ s/$pay/$my_replacement{$pat}/g; } print $text;
while (<fp>) { if (!m/^\s*\/\//) { # skip comments next; } $text .= $_; } foreach my $pat (keys %my_replacement) { $text =~ s/$pay/$my_replacement{$pat}/g; } print $text;
|
|---|