Peamasii has asked for the wisdom of the Perl Monks concerning the following question:
Hello, I have searched the archives for getting filesizes with File::Recurse in Windows and found this post:
Re: Filesize counting recursive
but when I tried the code it doesn't work. Getting an error about a HASH ref:
perl mp3size.pl
Directory: ./American Music Club - San Francisco
Can't use string ("./American Music Club - San Fran") as a HASH ref while "strict refs" in use at C:/Perl/site/lib/File/Recurse.pm line 36.
Here is my code. It's supposed to read any directory containing mp3's and sum their filesizes:
use strict; use File::Recurse; my $size; my %files = Recurse(['.'], {match => '\.mp3', nomatch => '\.html$'}); foreach (sort keys %files) { my $directory = $_; print " Directory: $directory\n"; Recurse(\&sum_size, $directory, \$size); print "Total size: $size\n"; } sub sum_size { my ($file, $total_size_ref) = @_; stat($file); unless (-d $_) { $total_size_ref += -s $_; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: getting filesize in windows
by rinceWind (Monsignor) on Aug 23, 2003 at 09:43 UTC | |
|
Re: getting filesize in windows
by thinker (Parson) on Aug 23, 2003 at 10:06 UTC | |
by Chady (Priest) on Aug 23, 2003 at 10:41 UTC | |
by Peamasii (Sexton) on Aug 23, 2003 at 22:45 UTC |