in reply to Re^3: Passing a string in a foreach loop
in thread Passing a string in a foreach loop
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"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Passing a string in a foreach loop
by GrandFather (Saint) on Oct 20, 2005 at 06:17 UTC | |
by mat001 (Initiate) on Oct 20, 2005 at 19:22 UTC |