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

I really loathe the “join with right+left delimiter” idiom for paired delimiters. Since you don’t need a map for this, let me demonstrate that extreme to show why I don’t like it:

my $joined = "(??{ \$pats[" . join( "] })|(??{ \$pats[", 0 .. $#pats ) + . "] })";

Uhm, oh dear.

Instead, I’d always prefer a map to put the delimiters in place before joining – it’s clearer, with less repetition of literals to boot. You’ve recognised the need for a map to clarify anyway – so take it to conclusion:

my $joined = join '|', map "(??{ \$pats[$_] })", 0 .. $#pats;

I think that looks a lot friendlier (than your code; to say nothing of my demonstration of atrocity).

Makeshifts last the longest.