Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: 'do' read file

by cdarke (Prior)
on Dec 14, 2011 at 08:51 UTC ( #943497=note: print w/ replies, xml ) Need Help??


in reply to 'do' read file

do will not alter lexical ('my') variables in the outer scope. To achieve this you have to use a package variable, so delare it using our.

However, using a file to set your variables can be dangerous, think carefully if you really need to do that. Why not put the keys/values into a file, read it in the normal way, and construct the hash yourself?


Comment on Re: 'do' read file
Download Code
Replies are listed 'Best First'.
Re^2: 'do' read file
by PhillipHuang (Sexton) on Dec 14, 2011 at 09:13 UTC
    I use 'use vars qw( %cfg );', it can print. and 'our' is also ok. 'vars NOTE: For variables in the current package, the functionality provided by this pragma has been superseded by our declarations, available in Perl v5.6.0 or later'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (17)
As of 2015-07-28 13:41 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 (255 votes), past polls