JKasting has asked for the wisdom of the Perl Monks concerning the following question:
I've got an array full of filenames (including paths) which I'm sorting into categories based on the filepaths. However, one of the categories is also based on the number of files in its folders. For instance, if the filepath contains the word "Paper", then it should be categorized as "paper". However, if there is more than 200 files in that filepath, then it should be categorized as "collection".
Here's what I'm doing now and it's not working correctly. Suggestions?
foreach $file (@file_list) { my $file_path = dirname($file); if ($file_path =~ m/paper/i){ my @files = <$file_path/*>; my $count = scalar(@files); if( $count < 200 ){ $category = "paper"; } else{ $category = "collection"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Counting files in a folder
by ikegami (Patriarch) on Feb 11, 2010 at 19:20 UTC | |
|
Re: Counting files in a folder
by scorpio17 (Canon) on Feb 11, 2010 at 19:37 UTC | |
|
Re: Counting files in a folder
by toolic (Bishop) on Feb 11, 2010 at 18:29 UTC | |
|
Re: Counting files in a folder
by lostjimmy (Chaplain) on Feb 11, 2010 at 18:23 UTC | |
by JKasting (Novice) on Feb 11, 2010 at 18:29 UTC | |
by lostjimmy (Chaplain) on Feb 11, 2010 at 18:47 UTC |