H
hsk
#!/usr/bin/perl -w
use File::Find;
my ( @dirs, $sum, $cnt, $dirname, $base_dir );
$base_dir = "D:\\temp";
find(\&wanted, $base_dir);
sub wanted {
$name = $File::Find::name;
if( -d $name )
{
push( @dirs, $name );
}
}
foreach my $d ( @dirs )
{
opendir( DIR, $d );
# set back to 0 size
$sum = 0;
foreach my $f ( readdir( DIR ) )
{
# set back to 0 size
$size = 0;
# if( -f $f )
unless( -d $f )
{
$size = (stat($f))[7];
$sum = $sum + $size;
}
}
close( DIR );
}
There is no error in case of 'if( -f $f ), but gets some errors for
'unless( -d $f )'. The error comes up in the line of '$sum = $sum + $size'
, saying 'Use of Uninitialized value.'
Is there any of who might give an answer for this?
OS: window 2000, ActivePerl 5.8 version
use File::Find;
my ( @dirs, $sum, $cnt, $dirname, $base_dir );
$base_dir = "D:\\temp";
find(\&wanted, $base_dir);
sub wanted {
$name = $File::Find::name;
if( -d $name )
{
push( @dirs, $name );
}
}
foreach my $d ( @dirs )
{
opendir( DIR, $d );
# set back to 0 size
$sum = 0;
foreach my $f ( readdir( DIR ) )
{
# set back to 0 size
$size = 0;
# if( -f $f )
unless( -d $f )
{
$size = (stat($f))[7];
$sum = $sum + $size;
}
}
close( DIR );
}
There is no error in case of 'if( -f $f ), but gets some errors for
'unless( -d $f )'. The error comes up in the line of '$sum = $sum + $size'
, saying 'Use of Uninitialized value.'
Is there any of who might give an answer for this?
OS: window 2000, ActivePerl 5.8 version