$str = "this\nis my short\nstring\n"; $regex = "my"; if ($str =~ /(.*$regex.*/) { print "Matched Line $1\n" }