Re: use modules OS dependent
- From: Jürgen Exner <jurgenex@xxxxxxxxxxx>
- Date: Mon, 14 Apr 2008 13:59:09 GMT
sledz@xxxxxxxxxxxx wrote:
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
port:
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 );
This is explained about halfway down in the documentation for "use".
The "BEGIN" forces the "require" and "import" to happen at
compile time.
What's the right way to write such an OS dependent application?
Don't use use() but an explicit require() and import() without the
enclosing BEGIN.
jue
.
- Follow-Ups:
- Re: use modules OS dependent
- From: Gunnar Hjalmarsson
- Re: use modules OS dependent
- Prev by Date: Re: use modules OS dependent
- Next by Date: Re: use modules OS dependent
- Previous by thread: Re: use modules OS dependent
- Next by thread: Re: use modules OS dependent
- Index(es):
Relevant Pages
|
|