use POSIX qw(ceil); sub roundup { my $num = shift; my $roundto = shift || 1; return int(ceil($num/$roundto))*$roundto; }