cybermack72 has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: special directory entries
by strat (Canon) on Dec 04, 2001 at 20:05 UTC
    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/*.*");
      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
      Howdy!

      Even clearer would be:

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

      yours,
      Michael

      Credit to Dominus' Program Repair Shop...

Re: special directory entries
by VSarkiss (Monsignor) on Dec 04, 2001 at 20:41 UTC

    Hmm. You posted the same question yesterday. Did you try any of the answers that were suggested there?

    I tend to think not, because you would have found that the grep function is built in to Perl on all platforms. It doesn't depend on the Unix program of the same name. (There are Win32 ports of the grep program, BTW.)