sub prematch (;$) { substr((@_ ? $_[0] : $_), 0, $-[0]) } sub match (;$) { substr((@_ ? $_[0] : $_), $-[0], $+[0] - $-[0]) } sub postmatch (;$) { substr((@_ ? $_[0] : $_), $+[0]) } my $foo = 'Hello, world!'; $foo =~ /o, w../; $\ = "\n"; print prematch($foo); print match($foo); print postmatch($foo); =head2 C, C, C Like C<$`>, C<$&> and C<$'>, but not slowing down, and needing a single argument: the string on which the most recent regex was performed. Uses C<$_> when no argument is given. =cut