use strict; use warnings; my ($dir, $file, $path); my ($script) = $0 =~ /:?([^:]+)$/; my @dirs = ':'; while ($dir = shift(@dirs)) { opendir(DIR, $dir); while ($file = readdir(DIR)) { next if $file eq $script; $path = "$dir$file"; if (-d $path) { push (@dirs, "$path:"); next; } ######### # Open each $path and process ######### } }