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