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

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?

Replies are listed 'Best First'.
Re^2: 'do' read file
by PhillipHuang (Beadle) 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?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (1)
As of 2021-10-28 02:58 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (95 votes). Check out past polls.