| ||||||
| 5/26 |
| 2004/9/2-3 [Computer/SW/Languages/Perl] UID:33302 Activity:kinda low |
9/2 How do I use a variable expansion in perl regex? Something like
$PATTERN = ".*foofoofoo";
$_ =~ s/$PATTERN//g;
Basically I'd like a C #define style expansion of $PATTERN. TIA
\_ The above should work. You might want to add the "o" flag to
the s/// operator for efficiency if your $PATTERN doesn't change.
\_ Also, you don't need to say "$_ =~ "; it's implied. |