Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: $[ is under respected.

by Anonymous Monk
on Aug 03, 2005 at 09:05 UTC ( [id://480406]=note: print w/replies, xml ) Need Help??


in reply to $[ is under respected.

Does anyone understand this:
my @foo = qw /foo bar baz quux/; $[ = 2; print $foo[2], "\n"; print $foo[1], "\n"; print $foo[0], "\n"; __END__ foo quux foo
If $[ is set to 2, $foo[2] is the first element (foo). It seems that $foo[1] is the last element (quux), which is logical because 1 == $[ - 1. But while 0 == $[ - 2, $foo[0] isn't equal to penultimate element (baz), but it's equal to the first element (foo) - as if $[ doesn't effect an index equal to 0.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://480406]
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-25 12:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found