in reply to Execute a for loop in many subdirectories

Don't know how many levels of subdirectories that you plan to search through, but you'll probably find File::Find (or File::Find::Rule, which I personally prefer to use) and the -X file test function to be useful.

  • Comment on Re: Execute a for loop in many subdirectories

Replies are listed 'Best First'.
Re^2: Execute a for loop in many subdirectories
by marlowvoltron (Novice) on May 22, 2014 at 20:34 UTC

    The depth is only 1, I don't need to go deeper than /antarctica/*

      The depth is only 1, I don't need to go deeper than /antarctica/*
      No need for File::Find then:
      my @dirs = grep -d, </antarctica/*>; for my $dir (@dirs) { chdir($dir) or die "Failed to chdir to $dir: $!"; execute_something(); }