in reply to Conditional for statement block (not just bare statement)

Yes. But why? What does that (and the fun provided by ikegami) buy you? What value does it add to your code to forsake a simple, traditional if block?

if ($true) { print "eenie\n"; }
versus
do { print "meenie\n"; } if ($true);
I can understand prefering a do-while over a while loop, but this is mostly pointless. I never write single line if statement anymore because i find they get in the way of debugging and growth. But I will use a do-while from time to time because it is necessary.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re^2: Conditional for statement block (not just bare statement)
by oko1 (Deacon) on Dec 17, 2008 at 01:24 UTC

    No disagreement with most of what you've written, but 'while' and 'do/while' have different purposes. I suppose that it can be considered a matter of preference, but IMO, forcing one to serve the purpose of the other is a bit square-block-into-round-hole-ish. :)

    do { print "Please enter $THING_TO_VALIDATE"; chomp($input = <STDIN>); } while THING_IS_NOT_VALID();

    --
    "Language shapes the way we think, and determines what we can think about."
    -- B. L. Whorf