in reply to Execute a for loop in many subdirectories

You will need -d to test for directoryness. You can also use glob
while (defined(my $subdir = glob 'antarctica/*')) { next unless -d $subdir; chdir $subdir; for ... chdir '../..'; }

or opendir and readdir:

opendir my $D, 'antarctica' or die $!; while (defined(my $dir = readdir $D)) { $dir = "antarctica/$dir"; next unless -d $dir; chdir $dir; for ... chdir '..';
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

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

    This looks like what I was trying to do... is there a distinct difference between these 2 approaches? Thank you!

      I am not sure. readdir might be better if there are millions of files in the antarctica directory, if I remember correctly.
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ