Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Re: How do I dynamically declare a package name for

by hdp (Beadle)
on Apr 27, 2001 at 16:09 UTC ( [id://76044] : note . print w/replies, xml ) Need Help??


in reply to Re: How do I dynamically declare a package name for
in thread How do I dynamically declare a package name for

This is actually unnecessary. Both use and require will look in %INC to make sure the file has not yet been included before loading it. (use will still call import again unless you explicitly pass it an empty list of symbols to import.)

hdp.

Replies are listed 'Best First'.
Re: Re: Re: How do I dynamically declare a package name for
by gildir (Pilgrim) on Apr 27, 2001 at 21:14 UTC
    Yes, but there is big difference when calling:
    eval { $object = $class->new; };
    and eval " $object = $class->new; "; In the former case, code is compiled as soon as it is first encountered by perl compiler, that is at compile time and it is compiled only once. While in the later case the code is compiled at run-time and is compiled every time the eval() is run.
    There is no way to do eval { use $class; }; so I must use eval " use $class; "; version, and I try to execute it as seldom as possible.