You are storing references in the masterarray, these are pointers to the actual data in the aaa, bbb and ccc arrays, not pointers to the array names. To get back to the array names you can do some voodoo searching of the symbol table with the reference values (returned in your second printing example).
The other way to do it would be to turn the problem on its head and store the actual names in masterarray and then use eval to find the values in there when you need them, something like this.
#!/usr/bin/perl use warnings; use strict; my @aaa = qw (11 22 33); my @bbb = qw (44 55 66); my @ccc = qw (77 88 99); my @masterarray = qw(aaa bbb ccc); print "$_ contains\t". (join ", ", eval "\@$_") . "\n" for @masterarra +y;
These arrays being lexical will not show in the symbol table, sorry. They are on the scratchpad space used for lexicals and there is a module to look into it called PadWalker. Good Luck !
you can also simplify the print doing it this way around if you use a symbolic ref (need to turn of strict refs for the scope)
{ no strict "refs"; print "$_ contains\t". (join ", ", @$_) . "\n" for @masterarray; }
Cheers,
R.
In reply to Re: printing array item reference names
by Random_Walk
in thread printing array item reference names
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |