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: ### jwkrahn Getit! pos=undef Matches: ### Eily Getit! pos=undef Matches: