http://qs321.pair.com?node_id=637481


in reply to Re: Regex code assertion should be able to fail
in thread Regex code assertion should be able to fail

Unless I'm missing something, the technique you describe is essentially the one I described in my original post as the technique I'd use in 5.8 (and was hoping for something more concise).

/(?(?{ whatever() })|(?!))/

Did I miss something?

Update: halley replied via /msg. His post was describing the same technique but gives more details for the benefit of on-lookers.

To clarify how I see this being used here's the code example from my patch to perlre:

@known_animal{ qw( cat dog fox horse rabbit rat ) } = (); @animals = /\b(\w++)(?{ exists $known_animal{$^N} }?)/g; print "@animals\n";