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

Re: Loading modules by external data (i.e., database)

by Corion (Patriarch)
on Jun 04, 2000 at 14:22 UTC ( [id://16284]=note: print w/replies, xml ) Need Help??


in reply to Loading modules by external data (i.e., database)

In my (frozen) file information display tool (a souped up magic program), I used dynamic loading for modules more or less like this :

$handler = eval( "use $modulename; return $modulename->new;" );
(I'm in a hurry, if this one dosen't work, tell me and I'll look up the actual code :))

Replies are listed 'Best First'.
RE: Answer: Loading modules by external data (i.e., database)
by Anonymous Monk on Jun 07, 2000 at 21:06 UTC
    That works just fine: $class = "my::Module"; $obj = eval("use $class; return $class->new;"); is the same as use my::Module; $obj = my::Module->new; But why does this work: use my::Module; $obj = my::Module->new($args_ref); When this doesn't: $class = "my::Module"; $obj = eval("use $class; $class->new($args_ref);"); $obj comes back undefined. Any ideas?

Log In?
Username:
Password:

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

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

    No recent polls found