H
Henry Law
There's an easy answer to this, I'm sure, but an hour of Googling and
experimenting has not led me to it. Can someone help?
I need to include the module Win32::File if my code is running on
Windows, but not on Linux. Job for the "require" statement, I thought.
The module exports a set of constants (ARCHIVE being my example), but
not, apparently, when "require" is used. How do I code this simple thing?
Code that does what I want on a Win32 system:
#! /usr/bin/perl
use strict; use warnings;
use Win32::File;
#require Win32::File;
#Win32::File->import qw(ARCHIVE);
printf "Archive constant from Win32::File: %x\n", ARCHIVE;
Commenting out "use" and making the "require" statement active gives
Bareword "ARCHIVE" not allowed while "strict subs" in use at ...
Also included above, commented out, is an unscholarly attempt to use the
"import" method, based on a Perl Cookbook recipe, but (a) it gives the
same error, and (b) the constants are exported automatically by
Win32::File without being specified, so I shouldn't have to code
"import" anyway.
experimenting has not led me to it. Can someone help?
I need to include the module Win32::File if my code is running on
Windows, but not on Linux. Job for the "require" statement, I thought.
The module exports a set of constants (ARCHIVE being my example), but
not, apparently, when "require" is used. How do I code this simple thing?
Code that does what I want on a Win32 system:
#! /usr/bin/perl
use strict; use warnings;
use Win32::File;
#require Win32::File;
#Win32::File->import qw(ARCHIVE);
printf "Archive constant from Win32::File: %x\n", ARCHIVE;
Commenting out "use" and making the "require" statement active gives
Bareword "ARCHIVE" not allowed while "strict subs" in use at ...
Also included above, commented out, is an unscholarly attempt to use the
"import" method, based on a Perl Cookbook recipe, but (a) it gives the
same error, and (b) the constants are exported automatically by
Win32::File without being specified, so I shouldn't have to code
"import" anyway.