in reply to Counting files in directory.

I won't give you the answer straight out (sounds a little like homework), but give you some points to consider.

If you are using this:

$counter++;

what do you think this would do?

print "$counter of $counter - $file\n";

You will need to capture the set of directory entries (@dirs = readdir...). Then you can iterate over the set of files, using the size of the @dirs variable as your total count.

--MidLifeXis

Replies are listed 'Best First'.
Re^2: Counting files in directory.
by Anonymous Monk on Sep 22, 2011 at 18:44 UTC
    my @files = <$dir/*>; my $count = @files;
Re^2: Counting files in directory.
by Anonymous Monk on Sep 22, 2011 at 19:13 UTC
    but I would like to the this counter while inside of the while loop.

      Until you finish the loop, you don't how many files are in the directory. You have to count how many files are in the directory before you can say "x is file z of z."


      Improve your skills with Modern Perl: the free book.