for $idx (0..$#hdr) { if ($row[$idx] ne "") { if ($found ne "N") { $updstmt .= ", "; $insstmt .= ", "; $valstmt .= ", "; } $found = "Y"; $updstmt .= $hdr[$idx]." = '".$row[$idx]."' \r\n";