in reply to RegEx Perl Code

vladb is right on as to the proper way to do this, but I thought I would comment on why it works that way.

When you ran your code, you probably got this error:

Eval-group not allowed at runtime, use re 'eval' in regex m/some((?{pr +int "Hey!";})/ at - line 6.
Basically, Perl really doesn't like running code that was interpolated into a string. Since a scalar used in a regex could very likely be input by a user, Perl avoids doing any sort of double interpolation (first interpolate the scalar into the regex, then run the code). If you do put
use eval 're';
because you know what you're doing, and put the paren at the end of the string that you seemed to forget, the code does what you expect.