2 ms·
It doesn't need an import at all. It's just a normal part of the language's syntax and can be used just about anywhere: $foo =~ /regex/ $result = $foo
by autoexec 9mo ago
It doesn't need an import at all. It's just a normal part of the language's syntax and can be used just about anywhere:
$foo =~ /regex/
$result = $foo =~ /regex/
if ($foo =~ /regex/) {whatever;}
while (/regex/) {whatever;}
The captures ($1, $2, etc.) are global and usable wherever you need them.
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