Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Empty pattern in regex

by jo37 (Deacon)
on Oct 19, 2023 at 07:07 UTC ( [id://11155038] : note . print w/replies, xml ) Need Help??


in reply to Empty pattern in regex

Maybe it's a bug, maybe it's an obscure feature. Anyway, this is a fragile construct for border-checking of the flip-flop operator as it will be broken by a regex match within the if-block.

The required information for such a check is provided by the flip-flop operator itself: it returns the current "loop number", with "E0" appended to the final loop call.

Here is a more robust version:

perl -le 'print for a .. h' | perl -nle 'if (my $ff = (/d/ .. /h/)) { +next unless $ff =~ /(?:^1|E0)$/; print }'

Greetings,
-jo

$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$