Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

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

by lalitbans (Novice)
on Feb 01, 2010 at 10:44 UTC ( [id://820705]=note: print w/replies, xml ) Need Help??


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

se Data::Dumper; @brr; @arr = (1,2,3,1); $flag; $len = scalar(@arr); $len = $len - 1; foreach $i(0 .. $len){ $length = scalar(@brr); if($length){ foreach $j(@brr){ if($j == $arr[$i]){ $flag = 'true'; last; }else{ $flag = 'false'; #push(@brr, $arr[$i]); } } if($flag eq 'false'){ push(@brr, $arr[$i]); } }else{ push(@brr, $arr[$i]); } } print Dumper(@brr);

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://820705]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-25 20:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found