Laudetur, monks. My problem is: In a given tree of subdirs, on the lowest level there are files, on other levels there aren't. In every subdir on the lowest level I'd like to select a certain file (newest from a certain type) and not process the others.
Now I've written a script, using File::find, which uses last to skip checking other files once I found one, thus skipping to the next directory. I think there are more elegant and/or efficient ways to this, I don't like using last.
Please share your thoughts. Thank you.
use strict; use warnings; use File::Find; my $dir = "d:\\Teszt"; finddepth(\&gotcha, $dir); sub gotcha { if ($dir eq $File::Find::dir){ print "same dir, skipping\n"; last; } else {$dir = $File::Find::dir;} if (-f) {print "$File::Find::name\n"; &process_files_in_subdir() } } sub process_files_in_subdir { ; #whatever }
In reply to File::find hack by nemesdani
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |