in reply to Re: N-Queens problem with a regex (again)
in thread N-Queens problem with a regex (again)

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 ! :-)))

Replies are listed 'Best First'.
Re^3: N-Queens problem with a regex (again)
by ikegami (Patriarch) on Aug 03, 2007 at 12:29 UTC
    It's my not-so-educated-guess that such an optimization is not likely. Such an optimization would be too specific, too little would be gained from the optimization, and it might break existing code.