Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: Create unique array --the hard way!

by Anonymous Monk
on Mar 07, 2014 at 15:56 UTC ( #1077405=note: print w/replies, xml ) Need Help??


in reply to Re: Create unique array --the hard way!
in thread Create unique array --the hard way!

Got it!
if ( ! grep ( /^$element$/, @unique_array ) )

Replies are listed 'Best First'.
Re^3: Create unique array --the hard way!
by jethro (Monsignor) on Mar 07, 2014 at 16:10 UTC

    Great that you found a solution yourself

    Since you didn't follow your own idea of using sorting to identify doubles the sort step is now useless.

    To follow your original plan you would have to do something like this:

    my $previous=""; foreach my $element ( @sorted_array_q3 ) { if ( $element ne $previous ) { push( @unique_array, $element ); } $previous= $element; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2021-12-07 19:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (34 votes). Check out past polls.

    Notices?