in reply to Counting files in a folder

Can you define "not working"?

It looks like you aren't using $category correctly. It must be scoped outside of the loop, so when you're finally outside the foreach loop, it just has whatever the last value assigned was. I would think you might want a hash keeping track of the category for each file instead. Something like: $category{$file} = "paper";

Replies are listed 'Best First'.
Re^2: Counting files in a folder
by JKasting (Novice) on Feb 11, 2010 at 18:29 UTC
    By not working, I mean that it is categorizing the file as "paper" when there are more than 200 files.
      OK well here are some things you can try:
      1. Are you sure you have the right directory in $file_path? File::Basename explicitly states that dirname does not always give the proper director, and that fileparse should be used instead.
      2. Are you sure the file glob is working? Does the @files array actually contain the files you are expecting?
      3. Are you sure you aren't just forgetting to use the $category at the appropriate time like I stated in my last post? I don't see anywhere in your code that you actually use $category, and so after exiting the loop you only have the last assigned value.