Welcome to the Monastery | |
PerlMonks |
DBI and Hashby elmic11111 (Novice) |
on Feb 13, 2012 at 21:02 UTC ( [id://953547]=perlquestion: print w/replies, xml ) | Need Help?? |
elmic11111 has asked for the wisdom of the Perl Monks concerning the following question: I have a script that reads a file and puts the data into my log database. The log file data is setup as KEY=>VALUE and as I read it I split it and put it in a hash array called sqlinsert. I prepare the insert query in advance using this code:
I then insert it with this code: $insertrow->execute(@sqlinsert{@dbfields});Works fine, untill recently when my log files were changed. In the new log file, each line of the log file doesn't always have all the fields. It only has the ones need for that transaction. This present a problem since I now have empty values. I tried setting up a foreach rounting like this hoping setting undef for the missing values would work, but perl complains when it does the excute about stuff not being defined:
What I like it to do is put a null value in for any field that doesn't have a value.
Back to
Seekers of Perl Wisdom
|
|