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:

my @db_values = split (/,/,$entry); next unless ( @db_values == 7 ); ## add this line $DB->sql("INSERT INTO Files ... ");
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 reply to Re: Most Annoying Error : Use of uninitialized value in concatenation (.) or string at C:\Perl\O by graff
in thread Most Annoying Error : Use of uninitialized value in concatenation (.) or string at C:\Perl\O by blackadder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.