I believe you that are way off base.

The original poster was attempting to access the element count for an array reference, and I provided the proper form to do this. The code that he was using $#{ @$arrayref } will force @$arrayref to a scalar context returning the element count "3" but will then attempt to dereference that string value (throwing an error if he has use strict turned on) and return -1 as the last index of an unrecognized array. This was obviously not what he desired.

It was certainly helpful that further contributers explained the origin of that code as taking advantage of a bug in older version of perl, but in the end what was needed was the proper form to access either the element count or the last index of an array reference, whichever it was that he wanted.

If I'm wrong, please specify how so, as my final suggestion was no different that what was provided by others later on

-Miller


In reply to Re^3: Perl 5.10.1 versus 5.8.8 with $#{} by wind
in thread Perl 5.10.1 versus 5.8.8 with $#{} by dirko.van.schalkwyk

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.