go ahead... be a heretic | |
PerlMonks |
Re: Most Annoying Error : Use of uninitialized value in concatenation (.) or string at C:\Perl\Oby graff (Chancellor) |
on Jul 15, 2005 at 12:21 UTC ( [id://475192]=note: print w/replies, xml ) | Need Help?? |
Grandfather is right. The warning is telling you that you are not checking the contents of @db_values before sending them into an operation where you might not want them to be undef (e.g. inserting a row in a database that contains nothing but null values). It's even telling you which line in the data file is causing the problem.
An easy way to avoid the warning -- and make sure you only insert rows that have the expected amount of actual data -- would be: You have another symptom of being too trusting: you pass $ARGV[0] to the open statement without checking to see if the user supplied an arg on the command line. In your case (opening a file for input), die would say "No such file or directory" after you get the warning "Use of uninitialized value in open". Oddly enough when I just now tested an open for output with nothing in @ARGV, I got no warning, no error, and no output file -- which makes it a really tricky thing to catch. (That seems like a perl bug, and worthy of a separate thread...) Anyway, you should always check input (from users or data files) before using it. update: forgot to mention -- are you sure you want to be using DBI to insert stuff into the database? It's very slow and you have to do all the work yourself (which you have not been doing yet) of checking that the values are appropriate before inserting them. I expect that your database engine (whatever it is) has its own tool or method for inserting data from a file, which will run a lot quicker (and value checks are likely to be built-in); note that you can (and should) use perl to condition data in advance if needed, and to run that tool.
In Section
Seekers of Perl Wisdom
|
|