I am currently looking into using structures in a program I am working on. For readability, I was wanting to use structures. Now I found the Class::Struct module and was using that, but then I found that Perl 5 Version 12.2 has Elaborate Records which are very similar to structures from what I can see. Now to build my skills with Perl, I am investigating how to use references, and references with arrays in these elaborate records.

The Problem:

I would like to learn how to retrieve the value for a reference to a scalar from an elaborate record and how to work with references to elaborate records.
my $stg_username = "PerlMonk"; my $stg_password = "VeryGoodPassword"; my @ary_email_address = [ "Monk1", "Monk2", "Monk3" ]; $EllabRecord = { m_username => \$stg_username , m_password => \$stg_password , m_emailAddress => \[@ary_email_address] }; print $stg_username; print $EllabRecord->{m_password}; #prints out "SCALAR (0xAABBCC)" &PrintArray( \$EllabRecord ); sub PrintArray { $reference = $_[0]; print $$reference->[m_emailAddress]->[0], "\n"; #gives a "Not an A +RRAY reference at...Line XX" }
If you can either provide me with clear code examples or a good guide to how this is done, either would be greatly appreciated. Thanking you in advance.

In reply to Elaborate Records, arrays and references by KyussRyn

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.