Beefy Boxes and Bandwidth Generously Provided by pair Networks Ovid
We don't bite newbies here... much
 
PerlMonks  

Re^2: Most Annoying Error : Use of uninitialized value in concatenation (.) or string at C:\Perl\O

by jhourcle (Prior)
on Jul 15, 2005 at 09:23 UTC ( [id://475213]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Most Annoying Error : Use of uninitialized value in concatenation (.) or string at C:\Perl\O
in thread Most Annoying Error : Use of uninitialized value in concatenation (.) or string at C:\Perl\O

It would also assume that there were no bad characters in the data being inserted, as there's nothing in the code to escape them.

In a situation like this, I'd use bind variables, nulls were allowed. I'd use 'em even if nulls weren't allowed, I'd just verify my data before trying the insert:

my $sth = $DB->prepare( 'INSERT INTO Files ( File_Path, File_Name, Siz +e_Byte, Created, Modified, Accessed, Type ) VALUES ( ?,?,?,?,?,?,? )' + ); foreach my $entry (@data) { next if ($entry =~ /^start|^Full/i); my @db_values = split (/,/,$entry); # do whatever value checking here ... checking for 7 values, etc. $sth->execute( @db_values ); }

It wouldn't be bad to check for errors after doing an execute, either:

$sth->execute( @db_values ) or warn $DB->errstr();
  • Comment on Re^2: Most Annoying Error : Use of uninitialized value in concatenation (.) or string at C:\Perl\O
  • Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://475213]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.