fiddler42 has asked for the wisdom of the Perl Monks concerning the following question:
Okay, I am making a rookie mistake, but I can't figure out how to work around it. I am employing the "use Getopt::Long;" module to process command-line arguments. One of the arguments is a string, and it can include regular expressions. Here is a simple example:-
$NetPattern = "mbist[\w+\d+\/]*\[\d+\]";
But when I try to compare that pattern to another variable like so...
if ($NetName =~ qr/$NetPattern/x) {# Do fantastical things...}
...and $NetName is "top_level/mbist_wrapper_pix2d[22]" the compare fails. If a user enters a command-line regular expression that gets pushed into a variable, what is the most reliable way to use that variable to compare it against another variable that is a string?
Thanks,
Fiddler42
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Comparing two variables when one variable includes a regexp...
by jettero (Monsignor) on May 01, 2008 at 15:04 UTC | |
by Narveson (Chaplain) on May 01, 2008 at 18:25 UTC | |
by jettero (Monsignor) on May 01, 2008 at 19:24 UTC | |
|
Re: Comparing two variables when one variable includes a regexp...
by toolic (Bishop) on May 01, 2008 at 15:30 UTC | |
|
Re: Comparing two variables when one variable includes a regexp...
by Anonymous Monk on May 01, 2008 at 17:21 UTC |