http://www.perlmonks.org?node_id=779011


in reply to move files to directories based on criteria

return if $File::Find::dir ne $root_dir;

You're traversing an entire tree even though you ignore all results from subdirectories. Very wasteful! I think the solution is:

sub wanted { my ($file)=$_; if (-d $file) { $File::Find::prune = 1; return; } my $dir_to_make = categorize($file); File::Path::make_path($dir_to_make); File::Copy::move($file, $dir_to_make); }

Error checking would be useful.