This does not work.use Win32::DirSize; open (FILE, "02_dir.txt") || die "can not open file\n"; chomp (@file = <FILE>); close FILE; $f = "d:\\programs"; #foreach $f (@file) { dsize($f); #} sub dsize { chomp (my $param = shift(@_)) ; print "$param \n"; my $Result = dir_size( $param, my $DirInfo, # this stores the directory information ); if ($Result == DS_RESULT_OK) { # If you don't want to display results in bytes, # let the module determine the best unit. my $Size = best_convert( my $SizeUnit, $DirInfo->{HighSize}, $DirInfo->{LowSize}, ); print "Dir size = $Size $SizeUnit \n"; } }
use Win32::DirSize; open (FILE, "02_dir.txt") || die "can not open file\n"; chomp (@file = <FILE>); close FILE; #$f = "d:\\programs"; foreach $f (@file) { dsize($f); } sub dsize { chomp (my $param = shift(@_)) ; print "$param \n"; my $Result = dir_size( $param, my $DirInfo, # this stores the directory information ); if ($Result == DS_RESULT_OK) { # If you don't want to display results in bytes, # let the module determine the best unit. my $Size = best_convert( my $SizeUnit, $DirInfo->{HighSize}, $DirInfo->{LowSize}, ); print "Dir size = $Size $SizeUnit \n"; } }
In reply to Re^4: Passing a string in a foreach loop
by mat001
in thread Passing a string in a foreach loop
by mat001
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |