Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: What array negative number counting means

by LanX (Saint)
on Jul 28, 2020 at 00:16 UTC ( [id://11119870]=note: print w/replies, xml ) Need Help??


in reply to Re^2: What array negative number counting means
in thread What array negative number counting means

(scalar @x) is the length of @x here 3

(scalar @x) - 1 == 2

In other words

$x[-y] is a shortcut for $x[(scalar @x) - y]

=>

$x[-1] eq $x[2] eq "light"

$x[-2] eq $x[1] eq "bar"

$x[-3] eq $x[0] eq "foo"

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^4: What array negative number counting means
by Anonymous Monk on Jul 28, 2020 at 00:22 UTC
    Thank you very much. :-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (7)
As of 2024-04-23 11:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found