On Oct 25, Girish (Skyscape) said: >%Replacements = ( > ";s(\d)", "<sup>$1</sup>" > ,";b(\d)", "<sub>$1</sub>" >);
Your problem is that these double-quoted strings get interpolated right here. "\d" is "d", and "$1" is whatever the value of $1 is at the time. You'll need to take a more involving approach: $inputstr = "E=mc;s2"; %rep = ( ';s(\d)' => '"<sup>$1</sup>"', ';b(\d)' => '"<sub>$1</sub>"', ); for $x (keys %rep) { $inputstr =~ s/$x/$rep{$x}/eeg; } print $inputstr; There are two levels of indirection here -- the first is the single quoted string '"<sup>$1</sup>"', and the second is that fact that that single quoted string has a double quoted string inside it. That's because we're using /ee on the s///, which means "eval() the right side twice". The first time, $rep{$x} evaluates to "<sup>$1</sup>", and the second time, it evaluates to a string, where $1 is interpolated. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]