in reply to conditionally include a module

Probably you want something like:

if ($^O eq 'MSWin32') { require Win32::OLE; }

Note that $ENV{OSTYPE} is not cross platform.


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: conditionally include a module
by syphilis (Archbishop) on Aug 23, 2007 at 11:44 UTC
    Note that $ENV{OSTYPE} is not cross platform

    Interestingly enough, there's a post just appeared on comp.lang.perl.misc pointing out that $^O is writable (can be modified) - on Windows, at least. I guess if we wanted to dot all of our i's and cross all of our t's we'd have to warn about that, too ... and recommend using $Config::Config{osname} (which actually is readonly) instead.

    Cheers,
    Rob

    Afterthought: Heh ... then again, $Config::Config{osname} can always be modified using tied ....