Hi,
I'm writing a module that will sometimes be used on Windows, and sometimes used
on Linux.
Unfortunately, on Windows, I need to be able to get the Process ID so I make
use of Win32:API. Of course this causes a problem when the module used on
Linux.
Here's my "ALMOST works" solution:
if($^O =~ /MSWin32/i){
require Win32::API;
my $GetCurrentProcessId = Win32::API->new("kernel32", "int
GetCurrentProcessId()");
my $PID = GetCurrentProcessId();
:
:
etc.
}
By pulling Win32::API in using "require" instead of "use" it is only evaluated
on demand so Linux is happy, but because I am using "require" instead of "use"
something is not quite right with the initialization so that on Windows perl
complains:
Win32::API::parse_prototype: WARNING unknown output parameter type 'int' at
C:/perl/site/lib/Win32/API.pm line 273.
Granted I get the $PID, but I'd like to get it properly, or at least without
the annoying warning message.
If I use "use" instead of "require" then Win32 seems to initialize properly,
but Linux cannot use the module at all.
Having one module for Linux and one for Windows is not an option.
If there a way or additional steps I can take to initialize Win32 without using
"use"?
Barry
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs