Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Re: BEGIN and 'use' question

by legLess (Hermit)
on May 07, 2002 at 20:47 UTC ( [id://164818]=note: print w/replies, xml ) Need Help??


in reply to Re: BEGIN and 'use' question
in thread BEGIN and 'use' question

Aha! That's the information I needed - thanks!
--
man with no legs, inc.

Replies are listed 'Best First'.
Re: Re: Re: BEGIN and 'use' question
by Elian (Parson) on May 08, 2002 at 05:48 UTC
    It's wrong, though.

    use is a compile time statement. As soon as the compilation phase gets to the end of the statement, the use is immediately executed. No conditionals will affect it (well, there's some stuff added recently, but we'll skip that for the moment) and it will happen. Throw a use inside a BEGIN block and all that'll happen is that the use will get used before the BEGIN block is fully parsed.

    If what you want is conditional inclusion, you need to do it the longer way, with require and import, both of which are runtime statements. Something like:

    BEGIN { if (DEBUG) { require foo; import foo; } }
    There's more documentation on this in the use section of perlfunc.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-26 00:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found