I can but agree on this. When I started learning perl, this was one of the things that definetely confused me. Not only is it a strange syntax to remember, but the only obvious mnemonic I could come up with -
# means a number, thus "number of elements" - is also wrong. Unless you count from zero, like perl does. ;-)
To be honest, I was never to satisfied with scalar @var either, even if it is logical when you get the idea of contexts, and that arrays return the number of elements in scalar context. That was not a given...
I really would like the simple function(s) length(@array) and possibly index_of_last(@array). Possibly with OO-syntax like @array.length(), and most certainly with a better name instead of index_of_last. :) But maybe I am a bit unortodox here, about perl... well, could I have those alternatives as well as something short?
And not to mention that lots of text editor's syntax coloring croak badly on $#var making the rest of the line a comment...
You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.