On 03/16/2005 09:50 AM, NIPP, SCOTT V (SBCSI) said:
Still banging my head into a wall... Now I am getting NULLs inserted as expected into the database, but I am getting errors on the compare.
my @old = $test->fetchrow_array (); foreach $n (0..20) { chomp($file_val = $data[$n]); $file_val =~ s/\s*$//;
chomp() is unneeded if it's followed by s/\s*$//.
#chomp($db_val = $old[$n+1]);
chomp() is unneeded and probably dangerous for values fetched
from the database. Is there a reason you are fetching an extra column from the database? You're comparing column[1] to field[0] ... column[21] to field[20].
#if ($file_val eq "") {
# print "NULL found in $n value. $file_val\n";
# $file_val = 0;
#}
# print "Comparing $file_val to $db_val. \n"; # Testing line
if (defined $old[$n+1]) {
if ($file_val eq $$old[$n+1]) {
You already noticed the extra '$'. Is this line 65?
$update = 1; } else { $update = 0; # print "Comparing $file_val to $db_val. \n"; # Testing line last; } } }
Here are the errors.
Name "main::old" used only once: possible typo at ./host_tbl_update2.pl line 65. Use of uninitialized value in string eq at ./host_tbl_update2.pl line 65, <CSV> line 1. Use of uninitialized value in string eq at ./host_tbl_update2.pl line 65, <CSV> line 2.
You probably need to change the NULLs you are now getting in the database back to "". I'd feel better about my diagnosis if I knew which line is line 65. Another possiblity is that $db_val is being used somewhere, but you've commented out where it was set.
-- Mac :}) ** I usually forward private questions to the appropriate mail list. ** Ask Smarter: http://www.catb.org/~esr/faqs/smart-questions.html Give a hobbit a fish and he eats fish for a day. Give a hobbit a ring and he eats fish for an age.
