Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

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?

What's my password?
Create A New User
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 chanting in the Monastery: (6)
As of 2015-10-07 19:39 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (200 votes), past polls