use strict; use warnings; my $string1 = "test1"; my $string = "test1"; my $re = qr/$string/; print "OK" if $string1 =~ $re;