Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
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 13:23 UTC ( [id://475213]=note: print w/replies, xml ) Need Help??


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
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2025-07-20 09:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.