Re: directory recursion


Subject: Re: directory recursion
From: Arthur Corliss (arthur@corlissfamily.org)
Date: Thu Mar 07 2002 - 22:17:00 AKST


> Why not just do it via a recursive function call? Thats the bad CS
> Programmer in my talking, but for easibility it will work awsome.

Yep, I haven't used the File::Find module in aeons, but something like the
following would work fine:

$dir = '.';

process_dir($dir);

sub process_dir {
   my $dir = shift;
   my @entries = grep !/^\.\.?$/, <$dir/*>;
   my $e;

   foreach $e (@entries) {
      if (-d $e) {
          process_dir($e);
      } else {
           # Do something to the file
      }
   }
}

--

--Arthur Corliss Bolverk's Lair -- http://arthur.corlissfamily.org/ Digital Mages -- http://www.digitalmages.com/ "Live Free or Die, the Only Way to Live" -- NH State Motto



This archive was generated by hypermail 2a23 : Fri Mar 08 2002 - 15:13:36 AKST