use modules OS dependent



I'm writing an perl script which should communicate over a serial
port. The script should be able to run in Linux and Win32
environments. In both environments exist modules to access the serial

Win32::SerialPort (under Windows)
Device::SerialPort (else)

I know it is possible to detect the OS using Config::Config. But it
seems not possible to use different modules depending on this
information like this:

if ( $OS eq 'WINDOWS' ) {
use Win32::SerialPort qw( :pARAM :STAT );
} else {
use Device::SerialPort qw( :pARAM :STAT );

What's the right way to write such an OS dependent application?


PS: Fup to comp.lang.perl.modules


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question