my $root_dir = '/top/directory/to/start/search';
RunDirs($root_dir);
sub RunDirs {
my $dir = shift;
opendir(TMP_D,"$dir") or die "$! opening $dir";
while(my $tmp = readdir(TMP_D)) {
$tmp = "$dir/$tmp";
if ($tmp =~ /\.\.?/) { next; }
if (-d $tmp) {
RunDirs("$tmp");
} elsif ($tmp =~ /^(\w*)\.(jpg|jpeg)$/) {
print "$tmp\n";
}
}
closedir(TMP_D);
}
####
-| ROOT
-|-| SUB 1
-|-|-| SUB 1.1
-|-|-|-| SUB 1.1.1
-|-|-|-|-| SUB 1.1.1.1
-|-|-|-|-| SUB 1.1.1.2
-|-|-| SUB 2.1
-|-| SUB 2
-|-|-| SUB 2.1
-|-|-| SUB 2.2
####
ROOT -> SUB 1 -> SUB 1.1 -> SUB 1.1.1 -> SUB 1.1.1.1