This is one of several of the Win32::* 'standard' modules I've encountered that have a pretty peculiar way of exporting constants.
In this case, they don't export the two quite specifically named functions into your namespace, but do export a dozen or so constants with very general names. But if you choose to import the function(s) you wish to use, the constants don't get exported!
That leaves you either fully qualifying them (as functions) or importing them manually, or using the functions fully qualified and having this random set of constants scribbled over your namespace!
To recap, you can do this:
#! perl -slw
use strict;
use Win32::File qw[ GetAttributes ];
while( my $file = glob $ARGV[0] ) {
GetAttributes( $file, my $attrs );
printf "%1s%1s%1s%1s%1s%1s%1s%1s%1s %s\n",
( $attrs & Win32::File::ARCHIVE() ) ? 'A' : ' ',
( $attrs & Win32::File::COMPRESSED()) ? 'C' : ' ',
( $attrs & Win32::File::DIRECTORY() ) ? 'D' : ' ',
( $attrs & Win32::File::HIDDEN() ) ? 'H' : ' ',
( $attrs & Win32::File::NORMAL() ) ? 'N' : ' ',
( $attrs & Win32::File::OFFLINE() ) ? 'O' : ' ',
( $attrs & Win32::File::READONLY() ) ? 'R' : ' ',
( $attrs & Win32::File::SYSTEM() ) ? 'S' : ' ',
( $attrs & Win32::File::TEMPORARY() ) ? 'T' : ' ',
$file;
}
Or this:
#! perl -slw
use strict;
use Win32::File;
while( my $file = glob $ARGV[0] ) {
Win32::File::GetAttributes( $file, my $attrs );
printf "%1s%1s%1s%1s%1s%1s%1s%1s%1s %s\n",
( $attrs & ARCHIVE ) ? 'A' : ' ',
( $attrs & COMPRESSED) ? 'C' : ' ',
( $attrs & DIRECTORY ) ? 'D' : ' ',
( $attrs & HIDDEN ) ? 'H' : ' ',
( $attrs & NORMAL ) ? 'N' : ' ',
( $attrs & OFFLINE ) ? 'O' : ' ',
( $attrs & READONLY ) ? 'R' : ' ',
( $attrs & SYSTEM ) ? 'S' : ' ',
( $attrs & TEMPORARY ) ? 'T' : ' ',
$file;
}
Or this:
#! perl -slw
use strict;
use Win32::File qw[ GetAttributes
ARCHIVE COMPRESSED DIRECTORY HIDDEN NORMAL
OFFLINE READONLY SYSTEM TEMPORARY
];
while( my $file = glob $ARGV[0] ) {
GetAttributes( $file, my $attrs );
printf "%1s%1s%1s%1s%1s%1s%1s%1s%1s %s\n",
( $attrs & ARCHIVE ) ? 'A' : ' ',
( $attrs & COMPRESSED) ? 'C' : ' ',
( $attrs & DIRECTORY ) ? 'D' : ' ',
( $attrs & HIDDEN ) ? 'H' : ' ',
( $attrs & NORMAL ) ? 'N' : ' ',
( $attrs & OFFLINE ) ? 'O' : ' ',
( $attrs & READONLY ) ? 'R' : ' ',
( $attrs & SYSTEM ) ? 'S' : ' ',
( $attrs & TEMPORARY ) ? 'T' : ' ',
$file;
}
Or this:
#! perl -slw
use strict;
use Win32::File ();
while( my $file = glob $ARGV[0] ) {
Win32::File::GetAttributes( $file, my $attrs );
printf "%1s%1s%1s%1s%1s%1s%1s%1s%1s %s\n",
( $attrs & Win32::File::ARCHIVE() ) ? 'A' : ' ',
( $attrs & Win32::File::COMPRESSED()) ? 'C' : ' ',
( $attrs & Win32::File::DIRECTORY() ) ? 'D' : ' ',
( $attrs & Win32::File::HIDDEN() ) ? 'H' : ' ',
( $attrs & Win32::File::NORMAL() ) ? 'N' : ' ',
( $attrs & Win32::File::OFFLINE() ) ? 'O' : ' ',
( $attrs & Win32::File::READONLY() ) ? 'R' : ' ',
( $attrs & Win32::File::SYSTEM() ) ? 'S' : ' ',
( $attrs & Win32::File::TEMPORARY() ) ? 'T' : ' ',
$file;
}
None of which seem particularly satisfactory from either a 'quick script-DWIM' or a software engineering point of view.
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.