in reply to Read In A File, Manipulate It, Spit It Back Out

I think that /g could prevent the recursion problem, so i have two way that would work :
# 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;
... and ...
while (<fp>) { if (!m/^\s*\/\//) { # skip comments next; } $text .= $_; } foreach my $pat (keys %my_replacement) { $text =~ s/$pay/$my_replacement{$pat}/g; } print $text;

may the foo be with you