in reply to Re^2: Program for Windows and Unix
in thread Program for Windows and Unix

The problem is that the use Win32::NetResource is being executed at compile-time, while the condition is tested later, at runtime.

See CountZero's reply for a way around it:  the module "if".

(Also, the string "aix" would need to be quoted... —> always use strict; )

Update: another way would be to use require (which is being executed at runtime):

unless ( $^O eq "aix" ) { require Win32::NetResource; Win32::NetResource->import(); # if you want any imports }

Replies are listed 'Best First'.
Re^4: Program for Windows and Unix
by DrHyde (Prior) on Feb 27, 2009 at 10:51 UTC
    Or you could eval 'use Win32::NetResource'.
Re^4: Program for Windows and Unix
by Richi (Initiate) on Feb 27, 2009 at 08:21 UTC
    Thank you!
    require is working!

      Note that 'require' does not run the 'import' method of the module. You may have to call import() yourself for some modules.

      Note also that if you require the module at runtime it will be too late to run any CHECK or INIT blocks in the module, so they will not be run. Some modules depend on these blocks being run. You can put the code to load the module in a BEGIN block to ensure it is run at compile time and that CHECK and INIT blocks are run.