>>>>> "Paul" == Paul Makepeace <[EMAIL PROTECTED]> writes:

Paul> This isn't really perl, but it might be mildly fun for a few seconds:
Paul>   $len += $page_size - $len % $page_size if $len % $page_size;

Paul> Any way of doing this in a single arithmetic expression, without the if?

$len = ($len + ($page_size - 1)) % $page_size + 1;

I first learned this trick to convert 0..23 into bands of 1..12:

$hour12 = ($hour24 + 11) % 12 + 1;

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Reply via email to