#/usr/bin/perl use strict; use warnings; use Readonly; my @volunteers = ( { name => "Ben", chunks => 5 }, { name => "Scott", chunks => 4 }, { name => "Jim", chunks => 1 }, ); my $current = 2192; Readonly my $CHUNKSIZE => 200; use List::Util qw(sum); my $total_volunteer_chunks = sum map { $_->{chunks} } @volunteers; sub volunteer_for { my $n = shift() % $total_volunteer_chunks; for my $v (@volunteers) { $n -= $v->{chunks}; if ($n < 0) { return $v; } } } for my $chunk (0..98) { my $end = $current + $CHUNKSIZE; my $victim = volunteer_for($chunk)->{name}; print "$current-$end\t\t$victim\n"; $current = $end + 1; }