$ perl -le '$r = qr/qux./; $s = "qux\n"; print "matches" if $s =~ /$r/' $ perl -le '$r = qr/qux./; $s = "quxxx"; print "matches" if $s =~ /$r./' matches $ perl -le '$r = qr/qux./; $s = "quxx\n"; print "matches" if $s =~ /$r./' $ perl -le '$r = qr/qux./; $s = "quxx\n"; print "matches" if $s =~ /$r./s' matches