in reply to how to dynamically declare a varialble?

It doesn't work because thats one of the main points of strict, you can't use symbolic references. If you want to use those references, turn off strict, but don't get mad if people yell at you.

I have no idea what your actual code looks like, but you might want to realize that m// will return a list of variables it captures in parens if you call it in list context, which will remove the need for symbolically accessing the capture variables. Example:
#badway /(foo)(bar)(baZ)/; if( $bar ) { return ${$bar}; }
(Contrived of course..)
#better way use strict; @matches = /(foo)(bar)(baz)/; if( $bar ) { return $matches[$bar]; }