Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: Reference assessment techniques and how they fail ($[)

by Jenda (Abbot)
on Apr 08, 2008 at 00:03 UTC ( #678861=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Reference assessment techniques and how they fail ($[)
in thread Reference assessment techniques and how they fail

Note that, unlike other compile-time directives (such as strict), assignment to $[ can be seen from outer lexical scopes in the same file. However, you can use local() on it to strictly bound its value to a lexical block.
       from perldoc perlvar

So I don't have to worry that someone will change mine $[ from within a different file that I used, but I still might run into problems if someone fiddles with $[ somewhere above my code in the same file.

@a = (0,1,2,3,4,5); sub pr { print "sub \$a[2]=$a[2]\n"; } print "\$a[2]=$a[2]\n"; pr; { $[ = 1; print "\$a[2]=$a[2]\n"; pr; } print "\$a[2]=$a[2]\n"; pr;

I refuse to worry anyway.


Comment on Re^3: Reference assessment techniques and how they fail ($[)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2015-07-29 00:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls