in reply to special directory entries

e.g.
unless (opendir(DIR, "c:/temp")){ die ("Error in opendir: $!\n"); } my @files = grep { $_ !~ /^\.{1,2}$/ } readdir(DIR); closedir(DIR);
or:
use File::DosGlob qw(glob); my @files = glob("c:/temp/*.*");

Replies are listed 'Best First'.
Re: Re: special directory entries
by demerphq (Chancellor) on Dec 04, 2001 at 20:17 UTC
    It is interesting to note that opendir/readdir is signifigantly faster than glob. But then again its less readable.

    Yves / DeMerphq
    --
    Have you registered your Name Space?

      @Yves: yes, that's true; I just prefer using File::DosGlob because it might turn the code a little bit clearer, and in addition to that allows you to ask only for files matching a pattern. But sometimes performance really is important. Best regards, Martin aka Strat
Re: Re: special directory entries
by herveus (Prior) on Dec 04, 2001 at 20:58 UTC
    Howdy!

    Even clearer would be:

    my @files = grep { $_ ne '.' && $_ ne '..' } readdir(DIR);

    yours,
    Michael

    Credit to Dominus' Program Repair Shop...