in reply to regex variables

you could just use regular expressions as hash values using qr// syntax, and then test your variable for match.

Better yet, your current code sample makes me think that you should think about rethinking your code design.

Best wishes,
Courage, the Cowardly Dog