Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Where is $# fully documented?

by ysth (Canon)
on Sep 23, 2014 at 17:25 UTC ( [id://1101688]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Where is $# fully documented?
in thread Where is $# fully documented?

Special function? No.

The a in @a is the identifier part of the variable name; the documentation addresses anywhere you'd put that a, which includes $#a.

Update: hmm, it does say "as part of a variable...name", implying it would only work if $#a is a considered a variable. I shy away from that because, even though it is an assignable lvalue, it really is just an attribute of an array variable. So the doc could use a minor tweak.

In any case, $#$arrayref / $#{$arrayref} ought to be added to the examples there.

--
A math joke: r = | |csc(θ)|+|sec(θ)| |-| |csc(θ)|-|sec(θ)| |

Replies are listed 'Best First'.
Re^4: Where is $# fully documented?
by LanX (Saint) on Sep 24, 2014 at 09:43 UTC
    > I shy away from that because, even though it is an assignable lvalue, it really is just an attribute of an array variable. So the doc could use a minor tweak.

    That's my point, I couldn't mentally map this behavior to normal dereferencing mechanics cause it rather feels like a magic feature.

    To make it more obvious, theoretically we could have a special syntax for keys and values of a hash ( like e.g. %<hash ).

    This would be a similar beast (/me struggling for a name ;)

    > In any case, $#$arrayref / $#{$arrayref}ought to be added to the examples there

    Definitely!

    Cheers Rolf

    (addicted to the Perl Programming Language and ☆☆☆☆ :)

      we could have a special syntax for keys and values of a hash ( like e.g. %<hash ).

      It couldn't be a variable since it's a list of values. It wouldn't make sense to give it the syntax of a variable since you couldn't do anything to it that you could do to a variable.

      Unless you mean keys in scalar context. That's an lvalue function that returns a magical variable like substr. As such, that could be made into a variable (e.g. keys(%h) = 123; could be made into %#h = 123;).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-03-19 02:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found