The only explanation I see missing here is how you might build any of these data structures and how to access the data you put into it.

# Declare an array and print out two elements my (@a) = qw( foo bar baz buz ); print join(", ", $a[0], $a[2]), "\n"; # Declare a reference to an anonymous hash and print # out some data from it my ($b) = { 'foo' => 'bar', 'baz' => 'baz' }; print join(", ", $b->{'foo'}, $$b{'baz'}), "\n"; # The following statement is quite odd. my (@c) = [ 'foo', 'bar', 'baz', 'buz' ]; # Perhaps you meant the following: my ($c) = [ 'foo', 'bar', 'baz', 'buz' ]; print join(", ", $c->[1], $$c[3]), "\n"; # Create a regular hash and print out some data: my (%d) = ( 'foo' => 'bar', 'baz' => 'buz' ); print join(", ", $d{'foo'}, $d{'baz'}), "\n";

Note that in the 2nd and 3rd cases I presented, there are 2 methods of accessing the data within the structure. You can either double the dollar sign ($$b{'baz'} or $$c[3]) or use the dereferencing characters ($b->{'foo'} or $c->[1]).


In reply to Re: data types by Coruscate
in thread data types by dave8775

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.