benedetto has asked for the wisdom of the Perl Monks concerning the following question:
I need to compare two arrays to make sure they do not share any of the same elements. For instance, if the two arrays are
@mammals = (dog, cat, mouse, horse, planet);
@sky = (star, planet, galaxy, nova, comet);
I want a program that would tell me, "planet is in both arrays." Or if no elements are shared, it would print "Both arrays are unique."
The actual arrays I have contain just numbers. Thousands of numbers, so it is too much to check them visually.
I have no clue how to do this.
Update
Should have written:
use strict; use warnings; @mammals = qw(dog cat mouse horse planet); @sky = qw(star planet galaxy nova comet);
Sorry. This is my first post.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Compare two arrays for uniqueness
by Kenosis (Priest) on Dec 16, 2013 at 04:51 UTC | |
|
Re: Compare two arrays for uniqueness
by Cristoforo (Curate) on Dec 16, 2013 at 04:49 UTC | |
|
Re: Compare two arrays for uniqueness
by AnomalousMonk (Archbishop) on Dec 16, 2013 at 05:05 UTC | |
|
Re: Compare two arrays for uniqueness
by Laurent_R (Canon) on Dec 16, 2013 at 07:13 UTC | |
|
Re: Compare two arrays for uniqueness
by Lennotoecom (Pilgrim) on Dec 16, 2013 at 08:38 UTC | |
|
Re: Compare two arrays for uniqueness
by benedetto (Initiate) on Dec 16, 2013 at 05:18 UTC |