--- "Hanson, Rob" <[EMAIL PROTECTED]> wrote: > > Much to my amazement, do() in perl is > > a STATEMENT BLOCK and not a loop! > > But that doesn't mean that you can't use it like one. > > In Perl you can use for/while/if/unless after a statement... > > print "Blue" if $x == 1; > print ++$x while $x < 10; > > The "do" lets you turn the for into a do-for, if into do-if, while into > do-while... etc. In other words it lets you use a block instead of just a > statement like in the examples above. > > So it still does what you expect... and then adds some functionaly beyond > that. > > Rob > > > > -----Original Message----- > From: Jeff Westman [mailto:[EMAIL PROTECTED] > Sent: Thursday, March 06, 2003 5:47 PM > To: beginners > Subject: Someone DO explain this to me! > > > In other languages, such as C, there is little difference between a while() > loop and a do-while() loop. The only difference of course being that that > do-while() loop will always execute at least once (test after), while the > while-loop does a test before.... > > Much to my amazement, do() in perl is a STATEMENT BLOCK and not a loop! > Yet > the while() construct is a loop. > > ________________________________________________ > > $ perldoc -f do > "do BLOCK" does not count as a loop, so the loop control > statements "next", "last", or "redo" cannot be used to leave > or restart the block. See the perlsyn manpage for alternative > strategies. > ________________________________________________ > > This seems odd to me. Yes, I know perl is not C or java or .... > > Thanks......... > > -Jeff > > > __________________________________________________ > Do you Yahoo!? > Yahoo! Tax Center - forms, calculators, tips, more > http://taxes.yahoo.com/ > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED]
__________________________________________________ Do you Yahoo!? Yahoo! Tax Center - forms, calculators, tips, more http://taxes.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]