$pat = "something with (.*?) in it"; $re = qr/$pat/; if ( $line =~ $re ) (or /$re/, same results) { $1 has nothing in it here. nor does $& or $` if ( $line =~ /$pat/ ) { $1 has the matched text in it here } }