Let's also accept your agument that it doesn't behave any differently than $array[42] as an rvalue.

I offer that it is a fact that a (even slightly) seasoned Perl programmer will instinctively use the $array[42] notation.

Then is there any argument you can make against warning about it when used as an rvalue (but not lvalue)?

The fact that most Perl programmers will prefer $array[42] over @array[42] is partially habit, but it's also influenced by this warning being discussed. Seasoned Perl programmers will use warning, if only during development, and if a programmer has two options of doing something, and one option issues a warning, which option do you think will be mostly used?

Let's not forget that Larry himself decided that $array[42] isn't right, and that it's now going to be @array[42] in perl6. Should then perl5 warn? I don't think so.

Furthermore, if you accept that (at least in rvalue context), both @array[42] and $array[42] are the same, why should there be a warning for one? If you cannot make a mistake, why suggest to the programmer he could have made one?

Abigail


In reply to Re: @array[1] is valid?? by Abigail-II
in thread @array[1] is valid?? by jdklueber

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.