Don't ask to ask, just ask | |
PerlMonks |
How can one find unique elements from arrays using a LOOP?by supriyoch_2008 (Monk) |
on Mar 04, 2014 at 10:30 UTC ( [id://1076848]=perlquestion: print w/replies, xml ) | Need Help?? |
supriyoch_2008 has asked for the wisdom of the Perl Monks concerning the following question: Hi PerlMonks, I am interested in finding the unique elements of each array from a set of input arrays (here only 3 arrays shown i.e. x,y & z). I have wriiten a script n.pl which can do this task easily and gives correct result. When the number of input arrays will increase to 200 or more, I intend to use the other script m.pl (given below) which makes use of a LOOP. But m.pl gives wrong result. I think the incorrect result is due to scalar varible "s" which does not change to scalar s1, s2, s3 etc. while passing through the LOOP. That is why the hexadecimal values of the array 's' are exactly same. I am looking forward to perl monks for suggestions so that I can use m.pl to input many arrays for comparison. Here goes the correct script n.pl
Correct results obtained from n.pl is given below:
Here goes the script m.pl (incorrect). I am interested to use either for LOOP, foreach LOOP or any other LOOP here:
The incorrect results of m.pl are:
Correct results of m.pl should look like:
Back to
Seekers of Perl Wisdom
|
|