SPUG: File::Find, skipping next directory

John Subaykan cansubaykan at hotmail.com
Mon Jan 6 13:33:09 CST 2003

I'm using File::Find to process a large number of files one directory down 
from where I am running the program.

I have several directories named something similar to this:


my $the_dir = "topdir";

my @tododirs = ($the_dir);

find({ wanted => \&do_it, no_chdir => 1 }, @tododirs);

süb do_it {

   return unless (-T $File::Find::name);

# during testing, I want to run tests on individual
# files, in this case, say I want to run the test on
# ./topdir/dir78/file78-100.html

   return unless $File::Find::name =~ /dir78\/file78-100\.html$/;

# if I put the above line to skip until I get to the
# file I want, I still have to wait for the script to
# check all the files starting from dir99 and working
# backwards (File::Find seems to sort descending?)

# even if I specify this:

   return unless $File::Find::dir =~ /dir78$/;

# it still looks at every file in the directories before 'dir78'.


so is there a way to skip the whole directory using File::Find without 
modifying the path of the starting directory (in my case e.g. without 
changing "topdir" to "topdir/dir78")?

a 'by-the-way' question; why do we use words like "Zub" or "[s]ub" on this 
email list to avoid typing the letters "s", "u", and "b" together?  I chose 
"süb" just to be different and I'm just asking because my name begins with 
these three letters.

John [S]ubaykan

The new MSN 8: smart spam protection and 2 months FREE*  

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org

More information about the spug-list mailing list