in reply to Not very perlish?

Here's another approach.
{ # Arguments to this function are in the order Pre, # Amble, and Post. Not sure why we're doing a modulo # 100 operation here unless it's a substitution for # the int() operator. my $Sum = 0; my @Values = map { $_ % 100, $Sum += $_, $_; } @_; if ( $Sum > 100 ) { # "If the sum is greater than 100 I wish to favour # amble, then pre, then post." my @Index = ( 1, 0, 2 ); my $ThisElement = 0; # Reduce values in selected order by brute force. # This could be done by calculation instead. while ( $Sum > 100 ) { $Values[ $Index[ $ThisElement++ % 3 ] ]--; $Sum--; } } elsif ( $Sum < 100 ) { # "If the sum is less than 100, post takes up the # slack;" $Values[ 2 ] -= 100 - $Sum; } # In all cases, return the variables, modified or not. return ( @Values ); }
Code is not tested.

--t. alex

"Nyahhh (munch, munch) What's up, Doc?" --Bugs Bunny