in reply to interpolation in replacement part
If you're doing this repeatedly in your program, though, it would be better to compile the regexes with qr and store them in an array rather than as keys in a hash.my %patt1; my $key = "<date>([A-Z&;][a-z&;]+), ([0-9]{2}) ([0-9]{4})</date>"; my $value = "qq|<month>\$1</month>|"; $patt1{$key} = $value; $instr = '<date>Jan, 10 1997</date>'; for my $pat (keys %patt1) { if ( $instr =~ s|$pat|$patt1{$pat}|eegs ) { print "match1: $instr\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: interpolation in replacement part
by Hue-Bond (Priest) on Oct 14, 2005 at 16:30 UTC |