Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Removing duplicate array elements

by Chief of Chaos (Friar)
on Feb 16, 2003 at 20:37 UTC ( [id://235794]=note: print w/replies, xml ) Need Help??


in reply to Removing duplicate array elements

Hi kumar, maybe this can help you :
#/usr/bin/perl -w use strict; my @array1 = ('one','two','one','three','four','two','one'); my @array2 = (); my $index; my $in; foreach $in (@array1) { push(@array2,$in) if (!grep $array2[$_] eq $in, 0 .. $#array2); } print "@array1\n"; print "@array2\n"; __DATA__ # the result : one two one three four two one one two three four
This is not the efficent dup-finder. But it is a "way".
C-o-C

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-18 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found