in reply to Multiline Regex replacement in Multiline file
Howdy akamboj84,
In the replacement part of your regex, $dic{$matchkey} will always be undefined. $matchkey is the variable you defined above by joining all the keys in %dic, and is therefore not itself a key of %dic. What you actually meant was:See the relevant section of perlvar.$line =~ s%$matchkey%$dic{$&}%g; # Use the matched string as a key +in $dic $line =~ s%($matchkey)%$dic{$1}%g; # Same as above without the perfor +mance issues of $&
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Multiline Regex replacement in Multiline file
by Athanasius (Archbishop) on Sep 15, 2014 at 09:37 UTC | |
by akamboj84 (Novice) on Sep 16, 2014 at 01:19 UTC |