Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: How to find and remove duplicate elements from an array?

by msk_0984 (Friar)
on Jul 20, 2007 at 07:17 UTC ( [id://627725]=note: print w/replies, xml ) Need Help??


in reply to How to find and remove duplicate elements from an array?

Yes this is the most asked questions in Perlmonks.
use strict; my @arr = ("A", "B", "ABB", "C", "ABB", "B","C" ); my %hash = (); my @list = (); foreach my $word (@arr) { push( @list,$word ) unless $hash{$word}++; } print join("\n", @list), "\n";

And this can help you out. Even I too was not able to pull out the distinct one from the array. So wat I did was went for "Search" or "Super Search"

So all of you it is always better to serach for the problem you are facing becos some one or the other has faced these kind of similar problems and have been solved by our respected monks. So please do search before to make any postings.

Thanks

Sushil

Originally posted as a Categorized Answer.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-23 19:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found