in reply to Re^3: Comment a block that match a keyword
in thread Comment a block that match a keyword
Whadda yer know. I made this same error 3 years ago, and despite being corrected, and accepting that correction from the ultimate authority, I'm still making it.
Does that say something about me? Or just confirm TimToady's reasoning for ditching the do{ ... } while construct.
For those not following along.
This
my $i = 0; while( $i < 5 ) { print ++$i; } 1 2 3 4 5
And this
my $i = 0; print ++$i while $i < 5; 1 2 3 4 5
Produce the same output.
And so do $i = 0; until( $i >= 5 ) { print ++$i }
And $i = 0; print ++$i until $i >= 5;
And $i=0; ++$i and print( $i ) while $i < 5;
And $i=0; ++$i, print( $i ) while $i < 5;
And even this $i=0; do{ ++$i; print( $i ) } while $i < 5;
But then suddenly, whilst $i=0; print( $i ) while $i++ < 5; this does.
This
$i=0; do{ print( $i ) } while $i++ < 5; 0 1 2 3 4 5
doesn't.
So, somewhere back there I've reached the conclusion that do{ } while is too subtle even for my tastes and stopped using it. As a result, I convinced myself that "Perl doesn't have a post-condition loop".
As you can see, I'm wrong. But for good reasons, and in line with those of some other people I respect, I'll continue to mentally deprecate it's usage.
With luck, this will act as an aide memoire to cause me not to voice my internal deprecation Perl does not have a post-condition loop out loud.
|
|---|