in reply to Using loops inside an 'if' statement

Of course when I tried it all sorts of error messages came up
Er ...
print "pre if() statement\n" if(@ARGV == 0) { my $n = 1; while(<DATA>) { print $n++, $_; } } print "post if() statement\n"; __DATA__ this totally works
When the above is run it outputs
pre if() statement 1: this 2: totally 3: works post if() statement
The point being, of course you can put a while statement or any other looping construct in a block if statement, and vice versa. Blocks in perl can take any and all valid code, as they are more or less just delimiters of scope.

What were the errors you were getting when you had the while in the if?

HTH

_________
broquaint