in reply to Stupid OO question
Are you asking how to load a module who's name you don't know at compile time? Here are some examples:
BEGIN { if( $^O =~ /Win32/i ) { eval 'use Win32::SerialPort qw(:ALL); 1;' or die $@; } else { eval 'use Device::SerialPort qw(:ALL); 1;' or die $@; } }
This gets the full effect of use with symbols imported at compile time so you can use them as barewords. But doing this is only useful if you know at compile time what symbols you want to import but not what module you want to import them from. That is a pretty rare situation.
$mod= "Junk::Stuff"; eval "require $mod; 1;" or die "$@"; $obj= $mod->foo("bar");
This is more likely what you want.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: Stupid OO question
by merlyn (Sage) on Aug 03, 2000 at 03:02 UTC | |
by tye (Sage) on Aug 03, 2000 at 06:42 UTC |