in reply to Iterating over code embeded in regex

I think you shouldn't use the (?{...}) construct without a very good reason. To run some code on all matches of a regexp in a string, you can do this for example (untested):

while ($string =~ /(pattern)/g) { do_something_with($1); }
Or, if you want overlapping matches too, then
while ($string =~ /(?=(patter))/g) { do_something_with($1); }