in reply to Subroutine Reference in a Regexp?

There's also the more familiar options of either building the regex as a string first, or using temporary variables:

# Temp str my $reg_str = '(\s'.getone().'\s'gettwo().')'; $str =~ /$reg_str/; # Temp scalars my $getone = getone(); my $gettwo = gettwo(); $str =~ /(\s $getone \s $gettwo )/xg;
It's easier to understand than @{[ LIST ]} or (??{ CODE }) patterns, and probably not noticeably slower, if at all.