in reply to Regex with variables?
Please note also that a subtitution substitues a pattern by a string, and not by a pattern. (This is probably what you meant, but some people try things like s!<a>\d{3}</a>!\d{3}! and wonder why it doesn't work)# first possibility $scalar = quotemeta('.*'); $foo =~ s/$scalar/string/; # second possibility chomp($scalar = <>); $scalar = quotemeta($scalar); $foo =~ s/$scalar/string/;
|
|---|