Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: If condition

by davorg (Chancellor)
on Jul 14, 2009 at 11:58 UTC ( #779887=note: print w/ replies, xml ) Need Help??


in reply to Re^2: If condition
in thread If condition

When I print $data_pair->{'key'} gives me all the keys present in the array
When I print $data_pair->{'values'} gives me all the values for the keys

Your data structure is strange :-)

I think you need something like this:

my ($cor, $date); for my $data_pair (@data_list) { if ($data_pair->{key} eq 'correct') { $cor = $data_pair->{value}; } if ($data_pair->{key} eq 'date') { $date = $data_pair->{value}; } } $sql_content .= qq( INSERT IGNORE INTO correct SET text="$cor", date="$date");

But as others have already mentioned, using DBI placeholders makes far more sense here.

--

See the Copyright notice on my home node.

Perl training courses


Comment on Re^3: If condition
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://779887]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (13)
As of 2015-07-30 16:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls