Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Arbritrarily requireing classes.

by Gilimanjaro (Hermit)
on Aug 03, 2004 at 16:14 UTC ( [id://379729]=note: print w/replies, xml ) Need Help??


in reply to Arbritrarily requireing classes.

The
eval "require $classFile;";
method is the one I use often. I'd name the variable $package though, because you're not actually naming the file.

I sometimes even eval a 'use', so the import get's run. Be sure to keep checking $@ afterwards though... Not doing so is asking for trouble. You may want to expand the die a bit, something like:
die "Error during dynamic require of $classFile:\n$@"
This'll just make the error messages a bit clearer for ya...

Log In?
Username:
Password:

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

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

    No recent polls found