Think about Loose Coupling | |
PerlMonks |
Array reference problemby hda (Chaplain) |
on Jul 07, 2009 at 15:52 UTC ( [id://777917]=perlquestion: print w/replies, xml ) | Need Help?? |
hda has asked for the wisdom of the Perl Monks concerning the following question:
Dear monks, I am working with a program in which some arrays must be accessed based on their names. I am experiencing a weird problem since some arrays can be accessed and others not. The example below should give an impression of how the problem goes. I have some arrays defined on some data and named as "@descriptor_array_(some number)". Then I have other arrays, named as "@array_dummy_(some number)" which I construct with data read from files and some number crunching. The thing is that I must access these arrays recursively based on their names, and for doing that I use a reference of the type:
Well, the problem is that the predefined arrays cannot be accessed whereas the others can. Both types are defined using "my" within the main loop of the program, and the loop where I call these arrays has the instruction "no strict 'refs'" Any thoughts??? UPDATE: $array_no is just an example, in my program the refernce is a string that I compose with sprintf.
Back to
Seekers of Perl Wisdom
|
|