my $regex = ; chomp($regex); $regex =~ s,^/,,; $regex =~ s,/$,,; my $txt = "The target string."; if ($txt =~ m/$regex/) { print "Yes.\n"; } if ($txt =~ $regex) { print "Yes.\n"; } __DATA__ /\bt\w+t\b/