$ cat t.pl use strict; use warnings; my $re1 = qr/p/; my $re2 = qr/t/; use re qw(Debug More); my @list = ('alpha', 'beta', 'gamma', 'delta'); for (@list) { print $_, "\n"; if (/$re1/) { print "has P\n" } if (/$re2/) { print "has T\n" } } $ perl -d t.pl <<< snip >>> main::(t.pl:4): my $re1 = qr/p/; DB<1> s main::(t.pl:5): my $re2 = qr/t/; DB<1> main::(t.pl:9): my @list = ('alpha', 'beta', 'gamma', 'delta'); DB<1> main::(t.pl:11): for (@list) { DB<1> main::(t.pl:12): print $_, "\n"; DB<1> alpha main::(t.pl:13): if (/$re1/) { print "has P\n" } DB<1> main::(t.pl:13): if (/$re1/) { print "has P\n" } DB<1> has P main::(t.pl:14): if (/$re2/) { print "has T\n" } DB<1> p { use re qw(Debug More); $re1=qr/g/; } Compiling REx "g" Final program: 1: EXACT (3) 3: END (0) anchored "g" at 0 (checking anchored isall) minlen 1 DB<2> s main::(t.pl:12): print $_, "\n"; DB<2> beta main::(t.pl:13): if (/$re1/) { print "has P\n" } DB<2> Guessing start of match in sv for REx "g" against "beta" Did not find anchored substr "g"... Match rejected by optimizer main::(t.pl:14): if (/$re2/) { print "has T\n" } DB<2> main::(t.pl:14): if (/$re2/) { print "has T\n" } DB<2> has T main::(t.pl:12): print $_, "\n"; DB<2>