in reply to Using loops inside an 'if' statement
Of course when I tried it all sorts of error messages came upEr ...
When the above is run it outputsprint "pre if() statement\n" if(@ARGV == 0) { my $n = 1; while(<DATA>) { print $n++, $_; } } print "post if() statement\n"; __DATA__ this totally works
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.pre if() statement 1: this 2: totally 3: works post if() statement
What were the errors you were getting when you had the while in the if?
_________
broquaint
|
|---|