#!/usr/bin/env perl use strict; use warnings; my %user_weight = (DREW => .5, TIM => 2,); my ($tot_users, $tot_non_weighted, $tot_events); while () { # Stuff data into Hash and get count of total events and users my ($user, $val) = split; $tot_events += $val; $tot_users++; $tot_non_weighted ++ unless exists $user_weight{$user}; } my $number_of_weighed_parts; $number_of_weighed_parts += $_ for values %user_weight; my $indiv_part = $tot_events / ($tot_non_weighted + $number_of_weighed_parts); print "The $tot_non_weighted non_weighted workers get each $indiv_part\n"; for my $weighted_user (keys %user_weight) { print "$weighted_user gets ", $indiv_part * $user_weight{$weighted_user}, "\n"; } __DATA__ TIM 150 JOE 124 JACK 111 KATE 145 DREW 177 #### $ perl weight.pl The 3 non_weighted workers get each 128.545454545455 DREW gets 64.2727272727273 TIM gets 257.090909090909