Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Seeking the right way to override global variables

by Athanasius (Archbishop)
on Sep 26, 2014 at 13:59 UTC ( [id://1102134]=note: print w/replies, xml ) Need Help??


in reply to Seeking the right way to override global variables

Hello contra-sh, and welcome to the Monastery!

I’ll just address one part of your question:

Seems like the override only works when I call the function. That's weird because I modified the value before including the logging module.

No you didn’t! use logging; is the same as BEGIN { require Module; }, which means that the code in “logging.pm” is loaded and run before the rest of the script begins running (because anything in a BEGIN block is run at compile time). Change that line in “run-unit-tests.pl” to require logging; and the output is:

23:48 >perl 1030_SoPW.pl Import... VAR1 : [override1] VAR2 : [override2] Running function... VAR1 : [override1] VAR2 : [override2] 23:48 >
- Should I see any difference if I use require instead of use?

Yes! (as just explained).

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Replies are listed 'Best First'.
Re^2: Seeking the right way to override global variables
by contra-sh (Acolyte) on Sep 26, 2014 at 14:41 UTC
    Thanks a lot. That's cristal clear right now :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-03-28 08:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found