Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Extracting Unique Characters from a Array

by mreece (Friar)
on Sep 07, 2006 at 17:41 UTC ( #571757=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @nums = qw(2 1 3 5 4 5 4 3 2 1);     # order is not important
    
    ...
        }
    }
    ## TODO: do something with @unique
    
  2. or download this
    my @nums = qw(2 1 3 5 4 5 4 3 2 1);    # order is not important
    my %seen = map { $_ => 1 } @nums; # build a hash; keys will be unique!
    @nums = sort keys %seen;       # replace old list with new sorted list
    ## TODO: do something with @nums
    
  3. or download this
    my @nums = qw(2 1 3 5 4 5 4 3 2 1);
    
    ...
        $previous = $current;     # 'current' becomes 'previous'
    }
    ## TODO: do something with @unique
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-09-20 11:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (158 votes), past polls