sub next_pwr { my ($x,$p) = (@_,2); # default to next_pwr(X,2) my $log = log($x)/log($p); $log = int($log+1) if $log != int($log); return $p**$log; }