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

Re: Create unique array --the hard way!

by kcott (Bishop)
on Mar 07, 2014 at 21:11 UTC ( #1077457=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/env perl -l
    
    ...
    my $last = '';
    my @unique = map { $last eq $_ ? () : ($last = $_) } sort @initial;
    print "Unique:  @unique";
    
  2. or download this
    Initial: q w e r t y q w e r t y
    Unique:  e q r t w y
    
  3. or download this
    #!/usr/bin/env perl -l
    
    ...
    __DATA__
    I am supposed to create a unique array
    I am not supposed to use hashes
    
  4. or download this
    Unique:  I a am array create hashes not supposed to unique use
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2020-08-13 14:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (73 votes). Check out past polls.

    Notices?