Arrays and hashes can both be used as lists, witness:
my %F = (a=>1, b=>2, c=>3); my @F = qw(a 1 b 2 c 3); foo(%F); foo(@F);
#New simpler code to avoid slices my %F = (a=>1); my @F = qw(a 1); foo(%F); foo(@F);
Within each code block both calls to foo pass the same values; @_(the parameters list) will be the same. NOTE: It is luck that the first works, as it relies upon the particular key/value pairs and how the current implementation of hashes in perl works.

Basically an array is an actual thing that lives somewhere and has an address (you can get a glob for it, you can use a reference to it), but that is not so for a list.

UPDATE: Modified code to ensure hash order prompted by dmmiller2k's reply. Which of course makes the comparison a little less clear since it uses slices. Added a second code block to reclarify

UPDATE I am an idiot. The sliced version only returned the values. And it did in fact work as advertised to begin with. It was just lucky that it did so. Added the NOTE, I really do understand this, but apparently I'm not very good at explaining it with code ;-)

--
perl -p -e "s/(?:\w);([st])/'\$1/mg"


In reply to Re: What is the difference between a list and an array? by belg4mit
in thread What is the difference between a list and an array? by sierrathedog04

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.