http://qs321.pair.com?node_id=506542


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;

Replies are listed 'Best First'.
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;