Re: use modules OS dependent



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
.



Relevant Pages

  • Re: port and managing of IIS
    ... Normally, i have 3 environments (development, test and ... production) on 3 differents servers. ... >>Is it save to create web site on other port than 80? ... >>does a list of port number exist to use with iis. ...
    (microsoft.public.inetserver.iis.security)
  • Re: use modules OS dependent
    ... port. ... The script should be able to run in Linux and Win32 ... In both environments exist modules to access the serial ... seems not possible to use different modules depending on this ...
    (comp.lang.perl.modules)
  • Re: use modules OS dependent
    ... port. ... The script should be able to run in Linux and Win32 ... In both environments exist modules to access the serial ... Petr Vileta, Czech republic ...
    (comp.lang.perl.modules)
  • Re: Porting application from old Smalltalk Version
    ... we are in your same situation and we had tested some environments to port. ... The part that involves more time/work to port is the GUI and there aren´t Smalltalks with exactly the same GUI framework. ... > Wich version is closest to class structure to VisualSmalltalk R3.1? ...
    (comp.lang.smalltalk)
  • use modules OS dependent
    ... I'm writing an perl script which should communicate over a serial ... port. ... In both environments exist modules to access the serial ... seems not possible to use different modules depending on this ...
    (comp.lang.perl.modules)