On 10/18/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> 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
>
I got a suggestion off-list to define "fake constants" on Linux for
the constants not available on Linux, e.g. "FILE_SHARE_DELETE". I
tried this, and it worked well. Now I no longer have to resort to
using "no strict".
So my current solution is:
BEGIN {
if ($^O eq "MSWin32") {
require Win32API::File;
import Win32API::File qw( :ALL );
...
}
else {
eval "use constant FILE_SHARE_DELETE => 'dummy'";
eval "use constant GENERIC_WRITE => 'dummy'";
...
}
}
Currently this is ok for me. My main problem was that I wanted to get
rid of "no strict" in my code. The fake constant trick solved this in
an acceptable way I think.
/Johan Holmberg
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs