#!/usr/bin/env perl my %user_weight = (DREW => .5, TIM => 2,); my $roundup; my $tot_per_user; my $tot_events; my $tot_users; undef %userMax4type; my @tmp; my $tmp=0; my $weight_tot=0; my %USERS; while () { # Stuff data into Hash and get count of total events and users my $aref = [split]; $USERS{$aref->[0]} = $aref->[1]; $tot_events += $aref->[1]; $tot_users++; } foreach ( keys %USERS ) { #check if a User has an assigned weight and perform calculation if ( exists($user_weight{$_}) ) { $tot_per_user = $tot_events/$tot_users * $user_weight{$_}; $roundup=sprintf("%.0f", $tot_per_user); print "roundup for $_ is: $roundup\n"; $weight_tot += $roundup; } else { #keep track of those users who do not have a weighting push @tmp, $_; $tmp++; } } #perform calculation on non-weighted users foreach (@tmp) { $tot_per_user = ($tot_events-$weight_tot)/$tmp * 1; $roundup=sprintf("%.0f", $tot_per_user); print "roundup for $_ is: $roundup\n"; } __DATA__ TIM 150 JOE 124 JACK 111 KATE 145 DREW 177