Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2014-08-28 06:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (257 votes), past polls