avarus.com.ar has asked for the wisdom of the Perl Monks concerning the following question:
This code does not really sets the lib path as expected but if I hard code this path instead of using this $libDir variable it simply works. So I decided to use a hardcoded lib path for testing purposes which exposed the next problem. In the directory "/home/avarus/perl/myPackages/" there is a package called "test.pm" which defines package "Test".my $libDir = "/home/avarus/perl/myPackages/"; use lib "$libDir";
this example works, but...use lib "/home/avarus/perl/myPackages/"; use test; # works
At the moment I am working around this problem with "require" and bla::blub constructs but then I don't have the functionality I want to make use of as described in perldoc perlobj. When I solved all those problems the next one is how I can create a new instance like this:use lib "/home/avarus/perl/myPackages/"; my $packageName = "test"; use $packageName; # does not work, segfaults
this of course does not work, but that's like I wanna do that :). It would be great if you can give me some hints. Thanks in advance, Andreas Schipplock.my $objName = "foo"; my $testObj = new $objName();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Loading and using packages dynamically
by moritz (Cardinal) on Aug 30, 2007 at 11:42 UTC | |
|
Re: Loading and using packages dynamically
by bruceb3 (Pilgrim) on Aug 30, 2007 at 12:06 UTC | |
by avarus.com.ar (Initiate) on Sep 24, 2007 at 19:53 UTC | |
|
Re: Loading and using packages dynamically
by FunkyMonk (Bishop) on Aug 30, 2007 at 16:12 UTC | |
|
Re: Loading and using packages dynamically
by SFLEX (Chaplain) on Aug 30, 2007 at 13:15 UTC | |
by Anno (Deacon) on Aug 30, 2007 at 13:33 UTC |