Hi!

I have a Perl application that should work on both Windows and Linux.
On Windows I use some of the Windows-specific modules, e.g.
"Win32API::File". So my code have things like:

1) "use Win32API::File qw( :ALL )  "
2) use of "constans" like GENERIC_WRITE and FILE_SHARE_DELETE.
3) calls to functions like Win32::File::CreateFile

In all my Perl-files i have "use strict". My problems at first on Linux are:

- the lines "use XYZ" where XYZ is a Windows module can't be used on
Linux. Somehow they have to be skipped.
- I get errors like 'Bareword "FILE_SHARE_DELETE" not allowed ...'

I am looking for the best way to manage this situation. Currently I
think I have found two possible ways forward:

A) make local changes in my files. For 1): replace "use" with "BEGIN +
require + import". Then I can skip Windows modules with a simple
if-statement in the BEGIN-block on Linux. For 2): as locally as
possible add "no strict" before the barewords are used. For 3): just
avoid calling the Windows functions on Linux.

B) move all Windows-stuff to a separate module, and apply the same
tricks as in A). Then I would get an extra indirection in function
calls, but that is probably not a problem. And I would have the
Windows stuff, and needed "tricks" in a single module.

Part of my "problems" are that I want my code to pass "use strict" as
much as possible *and* don't change any source files between Windows
and Linux. I also would like to avoid supplying any extra options on
the command line. A simple "perl myappl.pl" should work.

I have been looking for some #ifdef-like functionality, and only found
"use ifdef" that partially does what I want. But it seems to require
that one add extra options when invoking Perl ("perl -Mifdef=FOO
...").

Have I missed some other way of making this work in a good way?

/Johan Holmberg
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to