in reply to Dynamic array names
If you have a list of items to process and you don't know how long the list will be at compile-time, use a stack. In Perl, that's as simple as using push to add another element to an array. That's exactly what arturo suggests.
Attempting to keep track of a bunch of names generated on the fly can be tricky, and in this case, it's probably completely unnecessary.