in reply to Massive regexp search and replace
This could also allow testing if there is an regex you want to use 'exists()' (depending on input, eg change only certain column within csv file or something). But since I don't know if input is suitable for this, i can't know if exists could be used. If it could, you might be able to drop the second foreach loop completely.# assume REGEX is the pattern filehandle # asseme INPUT is the your input filehandle my %regex=(); while (<REGEX>) { chomp; my ($key,$value) = split (\t,$_); $value = "\"$value\""; $regex{$key}=$value; } while (<INPUT>) { s/$key/$regex{$key}/gee foreach my $key (keys %regex); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Massive regexp search and replace
by albert.llorens (Initiate) on Feb 10, 2005 at 13:31 UTC | |
by Hena (Friar) on Feb 10, 2005 at 14:05 UTC | |
by hsinclai (Deacon) on Feb 10, 2005 at 14:07 UTC |