Miker has asked for the wisdom of the Perl Monks concerning the following question:
is it possible to use a scalar variable in a regex?
As in:
Of course this doesn't work:) but is there something that makes it work? Thanks for any enlightenment, Mike$date = "dec"; @months_we_ski = ("nov", "dec"); foreach $month (@months_we_ski) { if ($month =~ /$date/) { print "yep, we ski in $month\n"; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: regex variables
by btrott (Parson) on Sep 01, 2000 at 03:24 UTC | |
(bbq) RE: regex variables
by BBQ (Curate) on Sep 01, 2000 at 18:33 UTC |
Back to
Seekers of Perl Wisdom