in reply to Counting files in a folder

Are there directories inside the directories? If so, I don't think the file glob method will count them all. It will just count the files inside the top-level directory (it will count directories, too, but not go down inside them).

I'd do something like this:

use File::Find; my $category; for my $file (@file_list) { my $file_path = dirname($file); # better make sure this is working! my $count = CountFiles($file_path); if ($count < 200) { $category = "paper"; } else { $category = "collection" } } # Count all files contained inside a directory, recursively sub CountFiles { my $dir = shift; my $count = 0; find( sub { if (-f) { # only count regular files ++$count; } }, $dir); return $count; }

Note that this way you can do things like not count zero-length files, or ignore symbolic links, etc. by simply changing the file test performed inside the 'find'.