Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: removing duplicate entries from an array

by neniro (Priest)
on Nov 07, 2005 at 21:49 UTC ( #506542=note: print w/ replies, xml ) Need Help??


in reply to removing duplicate entries from an array

Yet another way using junctions:

#!/usr/bin/perl use strict; use warnings; use Perl6::Junction qw/one/; use Data::Dumper; my @origin = (1, 2, 3, 2, 3, 4, 1, ); my @unique; for (@origin) { push @unique, $_ unless $_ == one(@unique) } print Dumper \@unique;


Comment on Re: removing duplicate entries from an array
Download Code
Re^2: removing duplicate entries from an array
by neniro (Priest) on Nov 07, 2005 at 22:17 UTC
    timtowtdi using Set::Scalar:
    #!/usr/bin/perl use strict; use warnings; use Set::Scalar; use Data::Dumper; my @origin = (1, 2, 3, 2, 3, 4, 1, ); my $s = new Set::Scalar; $s->insert(@origin); my @unique = $s->elements; print Dumper \@unique;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2015-07-02 06:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (30 votes), past polls