Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Matching elements inside two array

by Marshall (Canon)
on Apr 10, 2019 at 05:24 UTC ( [id://1232380]=note: print w/replies, xml ) Need Help??


in reply to Matching elements inside two array

There are multiple things wrong here.
Your code should always start with:
use warnings; use strict;
In general, an if within an if is wrong. This idea should be expressed if (X AND Y). That eliminates an indentation level and makes the code more clear. I have no idea what you are trying to do here..
if (grep { @input_B eq $_ } @input_array) { if (grep { @input_A eq $_ } @input_array) { foreach my $inputKey (@input_array)
Update: You ask "I have three arrays such as below. What I want to do is if the element inside the arrays match, then it will do something."

Please explain what a "match" between these 3 array's means? I could not deduce that algorithm from your post.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 05:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found