Query the OS name using $^O before requiring the module. See perlvar.
In reply to Re: Modules and crossplatform code by marto in thread Modules and crossplatform code by Khariton