Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Localizing Magic Variable? Should I?

by ikegami (Patriarch)
on Nov 17, 2009 at 22:43 UTC ( [id://807827]=note: print w/replies, xml ) Need Help??


in reply to Localizing Magic Variable? Should I?

If you were to localize them in stead of deleting them

First of all, localizing *them* wouldn't be equivalent. They'd still exist in the hash (with undef for value) rather than not existing at all.

Mind you, you can work around that:

local %ENV = %ENV; $ENV{'PATH'} = '/bin:/usr/bin'; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};

Or in 5.12+:

local $ENV{'PATH'} = '/bin:/usr/bin'; local delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};

That said, do you have a reason to restore %ENV? If not, why would you localize it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://807827]
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: (4)
As of 2024-04-20 00:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found