Here is how I solved it:
use if $^O eq "linux" , "Device::SerialPort" => qw( :PARAM :STAT 0.07 );
use if $^O eq "MSWin32" , "Win32::SerialPort" => qw( :PARAM :STAT 0.19 );
Thanks!
On 06/12/2011 03:13 AM, Dr.Ruud wrote:
On 2011-06-11 17:20, JP wrote:
How can I load a library depending on
On 2011-06-11 17:20, JP wrote:
How can I load a library depending on the platform I run on?
A use statement is always processed at compile time, no matter if there
are BEGIN blocks or if statements around it, or where it is in the source.
Check out "use if" (see perldoc if), or do the strin
On 11-06-11 11:20 AM, JP wrote:
How can I load a library depending on the platform I run on?
Try:
BEGIN {
use English qw( -no_match_vars );
if ( $OSNAME eq "linux" ) {
use Device::SerialPort qw( :PARAM :STAT 0.07 );
}
elsif ( $OSNAME eq "MSWin32" ) {
use Win32::SerialPort qw(
Hi all,
I need to load a different library, depending on the platform I am running on.
When running on Linux, I need "Device::SerialPort";
while running on Windows I need "Win32::SerialPort".
This is what I came up with:
if ( $OS eq "linux" ) { use Device::SerialPort qw( :PARAM :STAT 0.07 ); }