How to include a string variable in a regex (Perl)
I am wondering how do you include a string variable as part of a regex in Perl?
|
You just include the sigil + name in the regex, e.g. $f =~ m/blah$var/
|
Quote:
What if you meant $var literally? |
nope I just used the m out of habit. If you want a literal var, just escape the $.
|
So /$var/ for $var's value, and /\$var/ for the literal string '$var', right?
|
righty-o
|
All times are GMT -5. The time now is 09:14 PM. |