Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Occurence List

by aitap (Deacon)
on Oct 10, 2012 at 17:55 UTC ( #998276=note: print w/ replies, xml ) Need Help??


in reply to Occurence List

Use a hash:

use Data::Dumper; my @list = qw/ 1 1 1 234 234 3 5 5 2 7 6 3 6 8 4 /; my %count; $count{$_}++ foreach @list; print Dumper \%count; __END__ $VAR1 = { '6' => 2, '3' => 2, '234' => 2, '7' => 1, '2' => 1, '8' => 1, '4' => 1, '1' => 3, '5' => 2 };
Sorry if my advice was wrong.


Comment on Re: Occurence List
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2014-12-28 03:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (178 votes), past polls