- or download this
sub prematch {
return unpack "a$-[0]", $_[0];
...
my $len = $+[0] - $-[0];
unpack "x$-[0] a$len", $_[0];
}
- or download this
use strict;
use warnings;
...
print postmatch($string), "\n";
print match($string), "\n";
}
- or download this
my ($pre, $match, $post) = split /\b(word)\b/, $string, 2;