in reply to User defined function in while loop

Yes. This considers 1 as TRUE and 0 as FALSE:
use warnings; use strict; my $i = 0; while (foo($i)) { print "i = $i\n"; $i++; } sub foo { my $x = shift; return ($x < 5) ? 1 : 0; } __END__ i = 0 i = 1 i = 2 i = 3 i = 4