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 $_; } }
In reply to getting filesize in windows by Peamasii
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |