Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Perl 5.10.1 versus 5.8.8 with $#{}

by educated_foo (Vicar)
on Feb 02, 2011 at 00:27 UTC ( [id://885631]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://885631]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-19 21:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found