in reply to Re: Control Structures
in thread Control Structures

First, fork doesn't return -1 on error. It returns undef. Perhaps you were thinking of something else. (I hope that's not the way you've been coding your fork checking all this time!)

Second, as one odd way to solve your problem, you could execute one of a few code blocks:

( sub { print "A is less than B" }, sub { print "A is equal to B" }, sub { print "A is greater than B"} )[($a <=> $b) + 1)]->();
OK, maybe not much better, but at least you don't compute it more than once.

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.