$temp =~ m/(\[0-9\])blah$1/; #### $temp =~ m/(\[0-9\])blah\1/; #### #!/usr/bin/perl use strict; use warnings; for my $temp ("[0-9]blah[0-9]", "[0-9]blah6") { printf "%-15s ", $temp; if ($temp =~ /(\[0-9\])blah\1/) { print "matched\n"; } else { print "didn't match\n"; } } #### [0-9]blah[0-9] matched [0-9]blah6 didn't match #### Use of uninitialized value in concatenation (.) or string at ./671663.pl line 8. [0-9]blah[0-9] matched [0-9]blah6 matched