[ create a new paste ] login | about

Link: http://codepad.org/KZu1svPL    [ raw code | output | fork ]

sironekotoro - Perl, pasted on Sep 28:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use strict;
use warnings;

my @foods = qw(beef karikari beef kandume beef pork pork);

#重複排除 + count
my %hash;
for my $i(@foods){
    $hash{$i}++;
}

for my $i(sort {$hash{$b} <=> $hash{$a}} keys %hash){
    print "$i :$hash{$i}\n";
    }


Output:
1
2
3
4
beef :3
pork :2
kandume :1
karikari :1


Create a new paste based on this one


Comments: