If you really want @array[$i], which is something that I will probably dislike in Perl 6 then you can use the module Perl6::Variables

What follows are some useless arguments why I think $array[$i] is good...

Because you are refering to a scalar. An array (and a hash) can only contains a scalar.
By refering to a single element with $ you have the advantage (or not?) that you know that the prefix of the right part of the assigment has to be the same as the prefix of the left part.

This last thingie might make it easier to spot bugs if you are storing an array slice in a scalar (or not?).
If you put an array slice on the right part of the assigment (after the = that is) then it will return the last value, which might not be what you expected at all...

This would also enable you to build your own code checker which would check if each part of the assigment uses the correct prefix.


In reply to Re: The philosophy behind element reference syntax by Anonymous Monk
in thread The philosophy behind element reference syntax by jcoxen

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.