in reply to Using 'ord' in a regular expression for substitution

You don't. Try instead:

# Build a regular expression: my $regex = qr/ord(226)/i; # Use it to alter $string: $string =~ s/$regex/'/g;

Having said that, I doubt you want to use ord, as it converts a character into a number. I suspect you want chr which turns the number into a character...

Update: Ignore this stupid post, please.

...roboticus

Replies are listed 'Best First'.
Re^2: Using 'ord' in a regular expression for substitution
by JavaFan (Canon) on Aug 25, 2010 at 15:24 UTC
    What makes you think that $r = qr/STRING/i; s/$r/REPL/g; would work where s/STRING/REPL/ig; doesn't?

    qr/ord(226)/ fails in exactly the same way s/ord(226)/'/ig; does. Both match "ord226" and set (if matched) $1 to 226.