Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Extracting Unique Characters from a Arrayby rsriram (Hermit) |
on Sep 07, 2006 at 17:08 UTC ( [id://571748]=note: print w/replies, xml ) | Need Help?? |
Hi, Assuming that your array of numbers is: @array= qw/10 10 48 22 34 54 23 65 22/; The easiest way to do it is first sort the array @sarray=sort(@array); Now I am checking through every element in the array and storing it to a variable $last_element. The current element will be stored in $i. In the if condition, I am checking if the current element is equal to the last element and if the condition is false, I am printing the element. And here is the code:
You can have answers for these types of questions at Super search.
In Section
Seekers of Perl Wisdom
|
|