#!perl use strict; use warnings; my $base = shift; my $pattern = shift; print "Base = $base, pattern = $pattern\n\n"; my %checkthese; while ($base =~ m/\G($pattern)/g) { my $pos = pos($base); print "POS = ", $pos, "\n"; my $pre = substr($base,0,$pos - 1); my $match = $1; my $post = substr($base,$pos); $checkthese{"$pre:$match:$post"} = { pre => $pre, match => $match, post => $post, }; pos($base) = $pos + 1; } print "\n\n", "End", "\n\n"; print join("\n", keys %checkthese), "\n";