By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,933 Members | 1,676 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,933 IT Pros & Developers. It's quick & easy.

pick out common items from two arrays in a single statement

P: 4
I have two arrays,i want to take out common elements from
those two arrays in a single statement,

for example ;
two arrays are
my @a = (1, 3 ,4 ,7 );
my @b = (2 , 3 ,6 , 7);

i want to retrieve common elements that are 3 and 7 in a single
statement
Sep 13 '08 #1
Share this Question
Share on Google+
2 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
Then you are going to have to cycle through each array, comparing the elements to see if each is contained in the other.

Why not try coding that and post your code here, in code tags, if you have issues.

Regards,

Jeff
Sep 13 '08 #2

eWish
Expert 100+
P: 971
Have a look at perlfaq4 for starters.

--Kevin
Sep 13 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.