Hi,

try this function:

sub load_package {
   eval { my $p; ($p = $_[0] . ".pm") =~ s#::#/#g; require $p; };
   if ($@) {
     print STDERR "Perl Module $_[0] not installed. \n";
     print STDERR "exiting...\n";
     exit -1;
   }
}

call it liks this:

&load_package("Win32::NetResource") if $condition;

that should avoid those errors.

-Philip

On Wed, 31 Dec 1969, [EMAIL PROTECTED] wrote:
> I am developing a script that is to run on both NT and UNIX.
> 
> For the NT section the Win32::NetResource is required,
> but for obvious reasons it is not required when running in a UNIX 
> environment.
> 
> Is there a way to specify the dynamic loading of a module?
> 
> I have tried the Devel::SelfStubber and also 
> 
> BEGIN {
>        if ($condition) {
>            require Win32::NetResource;
>            local $@;
>            eval { Win32::NetResource->import() };
>        }
> }
> 
> This will load the module dynamically if under NT... but does not remove 
> the errors that appear because this module has not been installed in the 
> perl build under solaris.
> 
> 
> 
> 
> ---
> You are currently subscribed to perl-win32-users as: [EMAIL PROTECTED]
> To unsubscribe, forward this message to
>          [EMAIL PROTECTED]
> For non-automated Mailing List support, send email to  
>          [EMAIL PROTECTED]

---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
         [EMAIL PROTECTED]
For non-automated Mailing List support, send email to  
         [EMAIL PROTECTED]

Reply via email to