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 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 string-evalling yourself.


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to