http://www.perlmonks.org?node_id=87652


in reply to 0 illegal modulus?

I think that should be:

$ans = $y ? %x % $y : $x

Yes, this would work (but it still seems hackish). Thanks for the advice.