jethro has asked for the wisdom of the Perl Monks concerning the following question:
Just stumbled over this strange distinction:
evaluates the statement before checking the condition, butdo {$i++} until ($i==$x);
checks the condition first.$i++ until ($i==$x);
I find the second example quite surprising and the opposite of DWIM. And the inconsistency makes it even worse. Ok, postfix loop constructs shouldn't be used according to 'Perl Best Practices' for other reasons anyway. This is just one more reason.
But my restless mind wants to know: Why is that so? Just historical bagagge or is there some hidden justification for this?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: do {$i++} until vs. $i++ until
by Fletch (Bishop) on Mar 25, 2008 at 04:04 UTC | |
by jethro (Monsignor) on Mar 26, 2008 at 00:33 UTC | |
Re: do {$i++} until vs. $i++ until
by Anonymous Monk on Mar 25, 2008 at 04:13 UTC | |
by hipowls (Curate) on Mar 25, 2008 at 07:32 UTC | |
by ikegami (Patriarch) on Mar 25, 2008 at 08:36 UTC | |
by hipowls (Curate) on Mar 25, 2008 at 09:17 UTC | |
Re: do {$i++} until vs. $i++ until
by wade (Pilgrim) on Mar 25, 2008 at 04:49 UTC | |
by jethro (Monsignor) on Mar 26, 2008 at 00:55 UTC |
Back to
Seekers of Perl Wisdom