in reply to Re: Programmatic regex disjunction
in thread Programmatic regex disjunction

Probably not in Perl 5. But with Pugs I already can, and would.

my @pats = /one/, /two/, /three/; say "matched" if $string ~~ any @pats;

Then again, Perl 6 Rules have better composition, uh, rules, so there's likely a way to do it without a junction. One reason to insist is that where

$string ~~ any @pats

matches,

my $any = any @pats; $string ~~ $any;

does not. This means that I can't use a junction and a precompiled disjunctive pattern interchangably e.g. in a given block:

given $string { when $any { ... } # won't work if $any is a junction }

At least, that's how it operates now; I'd better ask on p6-l if that's the desired behavior. :-)

Update: come to think of it, it's almost certainly a pugsbug.