Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: filtering hidden files on Win32

by BrowserUk (Patriarch)
on Aug 30, 2002 at 10:36 UTC ( [id://194053]=note: print w/replies, xml ) Need Help??


in reply to filtering hidden files on Win32

The following snippet will do what you want.

#!perl -w use strict; use Cwd; use Win32::File qw(GetAttributes); use constant HIDDEN => 2; my $attribs; my $dir = cwd(); print $dir,$/; opendir( DIR, $dir ) or die "Couldn't open $main::DIR: $!\n"; my @vis_files = grep { -f $dir.'/'.$_ and GetAttributes($_, $attrib +s) and not ($attribs & HIDDEN) } readdir(DIR); closedir( DIR ) or warn "Couldn't close $main::DIR: $!\n"; print $_, $/ for @vis_files;

Now, I KNOW I shouldn't have to be defining my own HIDDEN constant, as this and all the others are apparently exported into main by Win32::File.

However, I have tried everything to use these exported constants including:

  • HIDDEN
  • $HIDDEN
  • Win32::File::HIDDEN
  • $Win32::File::HIDDEN

and either get 'bareword; noises, or if I turn off strict 'not numeric' noises.

I also investingated Win32::File.pm and whilst there is a qw( list ) of the constant names exported, I can see nowhere where they aquire any values?

Anyone who can explain

  1. How to use them?
  2. How they (are meant) to aquire values

Will earn the customary ++ and my grateful thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://194053]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-26 09:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found