in reply to while (my @row = $sth->fetchrow_array)

Please do the following changes:-

foreach (@Geo_areas) { $_ or next; my $Return_results = "Select * from Result_storage_keep where Ag +gregated_area LIKE '".$_."' \;"; my $sth_C = $dbh->prepare($Return_results) or die "Couldn't prep +are query: ".$dbh->errstr; $sth_C->execute() or die "Couldn't execute query: ".$sth_C->errs +tr; while (my @row = $sth_C->fetchrow_array) { foreach my $val (@row) { $val = '' unless defined; } print OUTPUT_FILE join("\t", @row); print OUTPUT_FILE "\n"; undef @row; } }
Don'y Use $_ for a list in the same loop for two times.

"Keep pouring your ideas"

Replies are listed 'Best First'.
Re^2: while (my @row = $sth->fetchrow_array)
by Errto (Vicar) on Jan 09, 2006 at 20:25 UTC
    Using a named variable on foreach loops is often a good idea from a readability standpoint, but the parent reply makes it sound like it will change the behavior. This is not true. foreach automatically localizes the index variable if it is a global. See perlsyn.