my $x = "ababa"; sub foo { \$x; } print join " ", @-, @+ while ${foo()} =~ m/a/g;