I don't know how to check that but doesn't that stringify then recompile the precompiled regexes?
Hm, that's a good question, I'm not sure at the moment how to check either... hopefully inspiration will strike later :-)
Your and jwkrahn's posts did remind me of a possibly important caveat: (??{...}) will re-execute the block of code every time, while interpolation will only execute it once:
use warnings;
use strict;
#use re 'debug';
my $str = "foobar";
sub getit {
print "Getit! pos=",pos($str)//"undef","\n";
return qr/[aeiou]/i;
}
print "### haukex\n";
print "Matches: <", $str=~/(??{getit})/g, ">\n";
print "### jwkrahn\n";
my $reg_str = getit();
print "Matches: <", $str=~/$reg_str/g, ">\n";
print "### Eily\n";
print "Matches: <", $str=~/@{[getit]}/g, ">\n";
__END__
### haukex
Getit! pos=0
Getit! pos=1
Getit! pos=2
Getit! pos=3
Getit! pos=4
Getit! pos=5
Getit! pos=6
Matches: <ooa>
### jwkrahn
Getit! pos=undef
Matches: <ooa>
### Eily
Getit! pos=undef
Matches: <ooa>
|