in reply to Re: Perl 5.10.1 versus 5.8.8 with $#{}
in thread Perl 5.10.1 versus 5.8.8 with $#{}

This is a shockingly unhelpful answer to the OP. Despite the fact that you apparently didn't (bother to) understand his question, you produced useless admonishments and code.
  • Comment on Re^2: Perl 5.10.1 versus 5.8.8 with $#{}

Replies are listed 'Best First'.
Re^3: Perl 5.10.1 versus 5.8.8 with $#{}
by wind (Priest) on Feb 02, 2011 at 01:08 UTC

    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