in reply to Comparing two variables when one variable includes a regexp...

Did you use warnings;? When I do, I get warning messages:
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"; }