in reply to Re^4: Passing a string in a foreach loop
in thread Passing a string in a foreach loop
Does the following code give the same result in both cases?
use warnings; use strict; use Win32::DirSize; my $f = "d:\\programs"; print "Manual call\n"; dsize($f); my @file = ("d:\\programs"); print "Loop call\n"; foreach $f (@file) { dsize($f); } sub dsize { chomp (my $param = shift(@_)) ; print ">$param<\n"; #... }
Note that you should always use strict; use warnings; to catch problems as soon as possible (I'm not implying they will help in this case, however ...)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Passing a string in a foreach loop
by mat001 (Initiate) on Oct 20, 2005 at 19:22 UTC |