Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks!
If I have the following code:
and I want to do this pattern matching:
it does not work because REC is right after the value of $myvar. Only if I separate them, e.g. $string="one#REC:riugfryfgfyug";
it does the pattern matching. Can you tell me what I am doing wrong?
If I have the following code:
$myvar="one"; $string="oneREC:riugfryfgfyug";
and I want to do this pattern matching:
if($string=~/^$myvarREC:(.*)/)
it does not work because REC is right after the value of $myvar. Only if I separate them, e.g. $string="one#REC:riugfryfgfyug";
it does the pattern matching. Can you tell me what I am doing wrong?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How do you use a variable value within a regular expression pattern properly? (updated)
by haukex (Archbishop) on Sep 11, 2017 at 11:43 UTC | |
Re: How do you use a variable value within a regular expression pattern properly?
by 1nickt (Canon) on Sep 11, 2017 at 11:30 UTC | |
by Anonymous Monk on Sep 11, 2017 at 11:38 UTC |
Back to
Seekers of Perl Wisdom