Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
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;

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;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://506542]
help
Chatterbox?
[1nickt]: choroba no kidding! The muscle memory alone makes it insignificant. I suppose the addition of param checking is nice. But if you are using MOo anyway you are using Type::Tiny, and you can easily use T::T for params in regular methods.
[choroba]: And regarding SQL, I'm usually generating SQL directly from queries supplied by the user, so I don't see how DBIx::Class can help me.

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2017-11-24 14:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (349 votes). Check out past polls.

    Notices?