Arrays are a pretty basic concept in Perl and any other language. Someone who needs this tutorial may also need help with concepts like scalar context and when it's implied.
I usually don't like something like this:
$count = @array;
It works, and it's clear, but mostly because of the variable names. Sometimes I've seen something more like:
$stuff = @things;
In that case, I think someone wrote a bug. It's clear what's meant if the scalar context is made explicit like so:
$stuff = scalar @things;
Otherwise, I have to read (perhaps a lot) more code to see how the variable is used and whether that makes sense, given its origin. When the scalar context is explicit, I can tell right away that the programmer really meant what was written.
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||