Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://998276]
help
Chatterbox?
[SwaJime]: Ran into an interesting piece of code today ...
[SwaJime]: select name,status, status2 from __ where status & status < 13 and status2 & 16 <> 16
[SwaJime]: I'm thinking that looks messed up. Sorry for OT ... but I know y'all are smart :-)
[SwaJime]: I expected items to not be selected if status was 0 ... but they were selected
[SwaJime]: any thoughts?

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2017-08-22 17:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (338 votes). Check out past polls.

    Notices?