Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use Text::CSV q(csv);
- use feature q(say);
- my $csv = csv(in => \*ARGV, headers => [qw(group name item)]);
- my $count = [];
- for my $c (@$csv) {
- my $d;
- for (@$count) {
- if ($_->{name} eq $c->{name}) {
- $d = $_;
- last;
- }
- }
- push @$count, ($d = { name => $c->{name} }) unless $d;
- $d->{all}++;
- $d->{hit} = 0 unless $d->{hit};
- $d->{hit}++ if $c->{group} <= 3;
- }
- $, = ',';
- for (sort {$a->{name} cmp $b->{name}} @$count) {
- say $_->{name}, $_->{hit} / $_->{all} * 100;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement