Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: How to match elements of array

by samarzone (Pilgrim)
on Dec 03, 2010 at 07:42 UTC ( [id://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

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

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2025-06-25 01:33 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.