Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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 wandering the Monastery: (2)
As of 2015-11-27 00:49 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (710 votes), past polls