By now you have the help you were looking for, but it may help a little to understand why Perl works like that. Larry Wall designed parts of Perl with the idea that different things should look different. That is a reason why Perl uses $, @ and % in front of variables and things. Things that have $ in front act like scalar values (numbers, strings and stuff like that). Things that have @ in front act like arrays or lists of things (don't get hung up about the difference at this point though). Things that have % in front act like hashes (those are really important to understand in Perl, but cause a lot of initial grief for beginners).

Arrays and hashes are both indexed variables - they hold lots of stuff and you need an index to select the particular element you are interested in. Arrays are indexed using numbers starting from 0 using syntax that looks like: $array[$index]. The $ out the front tells you that you are getting a scalar value. The [$index] bit selects the element 'indexed' by the numeric value in $index.

Hashes are indexed by strings. Accessing an element of a hash looks like: $hash{$index}. Still the $ out front to tell use we are getting a scalar value, but now we use curly brackets instead of square brackets and now $index contains any string we care to use.

Of course there is a whole lot more to it than that which you will learn along the way. Just remember that in general Perl tries to make things that are different look different.

True laziness is hard work

In reply to Re: simple array question by GrandFather
in thread simple array question by tw

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.