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;

update

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.

Pereant, qui ante nos nostra dixerunt!

In reply to Re: printing array item reference names by Random_Walk
in thread printing array item reference names by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.