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
|