Robert Zielfelder wrote: > I am trying to write a script that at one point needs to look at a number > and divide it by two. The results must always be an integer, but the > numerator can potentially be an odd number.
So you just want to divide by 2 rounding up the result. use POSIX qw/ceil/; my $half = ceil( $nr / 2 ); Of course, you could also use a direct Perl hack: my $half = int( $nr + 1 ); > What I want to do is if the > numerator is odd, increment it to the next highest even number. Is there a > function in PERL that will allow me to test weather or not an integer is odd > or even so that I can increment the number before I do the division? I would always suggest to express the algorithm directly, but it's of course also possible to find out whether a number is even or odd. One way is to use the modulo operator: if (($nr % 2) == 0) { # nr is even } else { # nr is odd } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]