This could be generalized to extract substrings, not just substring initial offsets; also to avoid $& which just slows everything down. (The many evals might slow things down, though. Oh, well...) (Also tested under 5.8.9.)
c:\@Work\Perl>perl -wMstrict -le
"use Data::Dumper;
;;
$_ = 'abcdfoofrobnicatebardefforspambazghi';
;;
my $re = qr{ (fo.) (.*?) (ba.) }xms;
;;
my %res;
while (/($re)/g) {
$res{$1} = [ map eval qq{\$$_}, 2 .. $#- ];
}
print Dumper \%res;
"
$VAR1 = {
'forspambaz' => [
'for',
'spam',
'baz'
],
'foofrobnicatebar' => [
'foo',
'frobnicate',
'bar'
]
};
Give a man a fish: <%-{-{-{-<