in reply to Re: Help on foreach loop
in thread Help on foreach loop

it still dosen't reset $newFile, for the first iteration $newFile = sample.txt in the next iteration $newFile is still sample.txt, and in my script I clearly move the sample.txt to another diretory after it was found the first time,

Replies are listed 'Best First'.
Re^3: Help on foreach loop
by Roy Johnson (Monsignor) on Sep 09, 2004 at 15:53 UTC
    Sounds like $ARGV isn't changing, possibly because the file isn't closed? Try closing ARGV within the while loop:
    @ARGV = <$responseDir/*>; while (<>) { $newFile = $ARGV, close ARGV, last if /^"$commonField"$/; }

    Caution: Contents may have been coded under pressure.