http://www.perlmonks.org?node_id=1012769


in reply to Broken Write function? Does anyone have Magic fixer ability?

You don't see any problems here?

$i = 0; my $filename2 = "invaildAddress"; $arrayLength = scalar(@addressSave); print $arrayLength ."\n"; open(IN2 , '>', $filename2); print IN "Invalid Addresses:\n\n\n"; while($i > $addressL){ ##########BROKE? print IN2 "City = " . $invalidAdd[$i]->{City} . "\n"; print IN2 "State = " . $invalidAdd[$i]->{State} . "\n"; print IN2 "Zip = " . $invalidAdd[$i]->{Zip} . "\n"; print IN2 "Address = " . $invalidAdd[$i]->{Address} . "\n"; print IN2 "Po Box = " . $invalidAdd[$i]->{PoBox} . "\n"; print IN2 "Suite = " . $invalidAdd[$i]->{Suite} . "\n"; print IN2 "Misc data = " . $invalidAdd[$i]->{MiscData} . "\n\n"; $i++; } close(IN2);

First you set $i to 0. Then you open a file with the handle "IN2" for output, but fail to check open for success. Then you print a line to the closed filehandle named "IN". Then you have a while loop that never executes because $i still holds zero, which should never be greater than $addressL. Since the only lines that print to IN2 are inside of a loop that never executes, you get no output. Within your loop at least you're trying to print to the correct filehandle.


Dave