Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Load perl module dynamically (use $object)

Reply
Thread Tools

Load perl module dynamically (use $object)

 
 
Markus Dehmann
Guest
Posts: n/a
 
      03-05-2006
Can I load perl modules dynamically?

In other words, I want to do something like this:

my $obj = "Getopt::Long";
eval{ use $obj } or die($@);

But it doesn't work like that. Is such a dynamic module loading possible
at all?

Markus
 
Reply With Quote
 
 
 
 
Brian McCauley
Guest
Posts: n/a
 
      03-07-2006

Christian Winter wrote:

> (my $pkg = $package) =~ s|:/|g; # require need a path
> require "$pkg.pm";


See also UNIVERAL::require

 
Reply With Quote
 
 
 
 
Brian McCauley
Guest
Posts: n/a
 
      03-07-2006

Brian McCauley wrote:
> Christian Winter wrote:
>
> > (my $pkg = $package) =~ s|:/|g; # require need a path
> > require "$pkg.pm";

>
> See also UNIVERAL::require


That should, of course, say UNIVERSAL::require

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to dynamically get an attribute from a module from withinthe same module Rafe Python 3 12-01-2008 11:53 AM
Re: module docstring, documentation,anything? please note is the module type/object NOT some module Maric Michaud Python 0 06-24-2006 12:42 PM
install_driver(Oracle) failed: Can't load 'C:/Perl/site/lib/auto/DBD/Oracle/Oracle.dll' for module DBD::Oracle: load_file:The specified procedure could not be found at C:/Perl/lib/DynaLoader.pm line 230. Feyruz Perl Misc 4 10-14-2005 06:47 PM
Load User Control Dynamically, Cast object dynamically =?Utf-8?B?UmV6YSBOYWJp?= ASP .Net 1 03-05-2005 12:04 AM
Load User Control Dynamically, Cast object dynamically =?Utf-8?B?UmV6YSBOYWJp?= ASP .Net 1 03-04-2005 07:57 PM



Advertisments