What you are trying to do is what is called symbolic references (see the documentation on references), and is deprecated and usually frowned upon by most people. The hash of arrays approach suggested above by
Kenosis is usually considered to be much better. If you really want to do it the way you said, you'll have to declare your variables with
our rather than
my and disable some of the strictures with the
no strict 'refs'; pragma. But, again, a HoA is certainly a better approach.