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 ...)


Perl is Huffman encoded by design.

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
    Thank you all that helped me with this problem. Like most problems it is the little things that screw up. The problem was in the dir.txt input file. I entered directories into the input file as \\\\\shaggy\\projects. This morning I changed the input file to read \\shaggy\projects and the code worked fine.
    Thank you again,
    mat001