It's simply a matter of saving the result then forcing a backtrack.
our @results;
/
... The work ...
(?{ push @results, ... })
(?!) # Backtrack to find next result.
/x;
Another question :)
Is it possible that, with a future version of regex engine, the piece
(?!) will be detected as an impossible match so the engine don't even try to match pieces before ?
See the huge difference between the two lines :
"abcde"=~/.*?(.)(?{print $1,"\n"})[0]/; #produce : abcde
"abcde"=~/.*?(.)(?{print $1,"\n"})0/; #nothing
Scary ! :-)))