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

you should do something like
my $cor ; my $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 .= "INSERT IGNORE INTO correct SET text='".$cor."', + date='".$date."'; }
I'm not sure if this is what you want, but it makes more sense to me!
And as mentioned already, use placeholders!!

UPDATE: Hmmm, this doesn't make much sense too :) but I hope it helps!

Replies are listed 'Best First'.
Re^4: If condition
by ashish.kvarma (Monk) on Jul 14, 2009 at 12:22 UTC
    It will make more sense if you move assignment to $sql_content out of loop. You probably want something like
    my $cor ; my $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'}; } } my $sql_content = "INSERT IGNORE INTO correct SET text='".$cor."' date +='" .$date."'";
    If this is what we are looking for than try this as well
    my %data_hash = map {$_->{'key'} => $_->{'value'} if ($_->{'key'} eq ' +correct' || $_->{'key'} eq 'date')} @data_list; my $sql_content = "\nINSERT IGNORE INTO correct SET text='".$data_hash +{'correct'}."' date='" .$data_hash{'date'}."'";
    Regards,
    Ashish