$foo =~ /regex/ $result = $foo =~ /regex/ if ($foo =~ /regex/) {whatever;} while (/regex/) {whatever;}
In this particular case the default is that $ matches the end of a string without a newline but you can include it anytime you need to:
$foo =~ /regex$/ # end of string without newline $foo =~ /regex$/m # end of string with newline
In this particular case the default is that $ matches the end of a string without a newline but you can include it anytime you need to: