Unrecognized escape \w passed through at ./683940.pl line 6. Unrecognized escape \d passed through at ./683940.pl line 6. Unrecognized escape \d passed through at ./683940.pl line 6.
This is my version of your code:
#!/usr/bin/env perl use warnings; use strict; my $NetName = 'top_level/mbist_wrapper_pix2d[22]'; my $NetPattern = "mbist[\w+\d+\/]*\[\d+\]"; if ($NetName =~ qr/$NetPattern/x) { print "match\n"; } else{ print "no match\n"; }
One solution is to avoid interpolation (as jettero has already mentioned).
#!/usr/bin/env perl use warnings; use strict; my $NetName = 'top_level/mbist_wrapper_pix2d[22]'; my $NetPattern = 'mbist[\w+\d+\/]*\[\d+\]'; if ($NetName =~ qr/$NetPattern/x) { print "match\n"; } else{ print "no match\n"; }
In reply to Re: Comparing two variables when one variable includes a regexp...
by toolic
in thread Comparing two variables when one variable includes a regexp...
by fiddler42
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |