| sonamc@gmail.com 2006-05-25, 3:58 am |
| Hello - I wanted some advice writing a cross-platform Perl script...
I have a Perl script running a testing framework. It uses a CPAN module
(Proc::ProcessTable) which is only supported on Cygwin/Windows and
UNIX, but not on ActivePerl. Until now, it only ran on UNIX and Cygwin,
so this wasn't a problem.
Recently, it became necessary to support testing with the
Windows-specific SAMIE tool (http://samie.sourceforge.net/ ) which uses
Win32::* modules including Win32::GuiTest. ActivePerl supports Win32::*
without a problem, but not Proc::* modules. I tried installing Win32
modules on Cygwin but hit problems with Win32::GuiTest. The mailing
list for that module (http://groups.yahoo.com/group/perlguitest/) says
it isn't supported on Cygwin as it is compiled with Visual C++ but
Cygwin uses gcc.
My question: how can I make a unified cross platform Perl script expose
UNIX-specific functionality on UNIX, and Win32 functionality on
Windows? I tried implementing a conditional 'use' statement like
the one below, but it fails with a "Can't locate Win32/GuiTest.pm in
@INC".
-------------------------
if ($^O eq 'cygwin') {
use Proc::ProcessTable;
unix_specific_stuff();
} elsif ($^O =~ /MSWin/) {
use Win32::GuiTest;
windows_specific_stuff();
}
-------------------------
Is there a clean way to do this?
Sincerely,
Sonam Chauhan
|