in reply to Regex with variables?

Adiing to what the others said, if $scalar does not contain a RegEx, but a string that you want to match, you might be interested in the quotemeta(...) function, which avoids, for example, $scalar = '.*'; to match the whole string and transforms it to \.\*. Just do something like
# first possibility $scalar = quotemeta('.*'); $foo =~ s/$scalar/string/; # second possibility chomp($scalar = <>); $scalar = quotemeta($scalar); $foo =~ s/$scalar/string/;
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)
Cheers, CombatSquirrel.