Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: How to match elements of array

by samarzone (Pilgrim)
on Dec 03, 2010 at 07:42 UTC ( #875087=note: print w/ replies, xml ) Need Help??

in reply to How to match elements of array

You have already got a better approach from PeterPeiGuo but if you are curious about what's wrong in your code, here are a few things which I noticed

  1. You are not comparing the names, rather you are comparing the existence of names in db and in the array.if(($row->{image_name_1} ne "") eq ($pics[0] ne "")) will increment $flag_pic even if $row->{image_name_1} is "xyz" and $pics[0] is "abc"
  2. (Let us assume previous error is corrected) You are assuming the order to be same in db and in array. If name in first row of db matches with that of second element in the array, it will go unnoticed and you will fire an "insert" query.

You definitely need to modify the approach

Comment on Re: How to match elements of array
Select or Download Code
Replies are listed 'Best First'.
Re^2: How to match elements of array
by Anonymous Monk on Dec 03, 2010 at 12:01 UTC
    I am not trying to increment anything, I am trying to assignment a value so it can be true down on the IF statement if the element of the array "@pics" will match or be the same as the one found in the database.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (18)
As of 2015-11-30 15:58 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (776 votes), past polls