Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

eval require

by Anarchy (Initiate)
on Nov 07, 2012 at 19:39 UTC ( #1002725=perlquestion: print w/ replies, xml ) Need Help??
Anarchy has asked for the wisdom of the Perl Monks concerning the following question:

If you do a eval require with a subroutine, then are you able to use that module used in the require statement when you are no longer inside that subroutine?

Comment on eval require
Re: eval require
by Fletch (Chancellor) on Nov 07, 2012 at 20:01 UTC

    You didn't try it, did you? Please say no. I mean you must not have tried it on your own because the spacetime continuum still exists. Who knows what kind of deviltry could have been unleashed had you experimented and tried to answer a trivial question empirically.

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

Re: eval require
by chromatic (Archbishop) on Nov 07, 2012 at 20:37 UTC

    Yes. Module symbols are globally visible.

    With that said, be aware of the difference between using use which takes effect at the point of compilation (such as importing symbols into your namespace) and eval which takes effect as the program runs (and which won't let you refer to those symbols with unqualified names).


    Improve your skills with Modern Perl: the free book.

Re: eval require
by blue_cowdawg (Prior) on Nov 07, 2012 at 20:50 UTC
        If you do a eval require with a subroutine,

    Why do you insist on making your life complicated? Just do the darn require....


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1002725]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2014-08-29 05:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls