my $re = quotemeta($str2); if( $str1 =~ /^$re/ ) { print "match\n"; } else { print "nomatch\n"; }