Help for this page

Select Code to Download


  1. or download this
    my %vals_by_type;
    while (<DATA>) {
    ...
        my ($type, $val) = split ' ';
        push @{ $vals_by_type{$type} }, $val;
    }
    
  2. or download this
    use List::Util qw( sum );
    
    ...
        my $avg = sum( map $_/@$vals, @$vals );
        printf("%s %.2f\n", $type, $avg);
    }