coreolyn has asked for the wisdom of the Perl Monks concerning the following question:
I'm going through some finer details of Perl and I came across the availability of an optional continue block available with use of a while conditional structure.
The examples I've found for its use go like this:
From Programming Perl 3rd ed.
while (my $line = <STDIN>) { $line = lc + $line; } continue { print $line; #still visible } # $line now out of scope here
From Elements of Programming with Perl
my $count = 0; while ( $count < 10 ) { print "$count\n"; } continue { $count++; }
The first example is nice for showing that the scope extends over the entire structure, and the second is nice for showing how to turn a while into an awkward looking for loop. I should point out that all references to the continue block explicitly say that it is a seldom used construct.
My curiosity is two-fold:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: while 's 'continue' block
by merlyn (Sage) on Jan 04, 2001 at 21:33 UTC | |
by coreolyn (Parson) on Jan 04, 2001 at 21:44 UTC | |
by extremely (Priest) on Jan 05, 2001 at 01:15 UTC | |
|
(tye)Re: while 's 'continue' block
by tye (Sage) on Jan 04, 2001 at 21:54 UTC | |
|
Re: while 's 'continue' block
by turnstep (Parson) on Jan 04, 2001 at 21:28 UTC | |
|
Re: while 's 'continue' block
by I0 (Priest) on Jan 04, 2001 at 21:38 UTC | |
by coreolyn (Parson) on Jan 04, 2001 at 21:59 UTC | |
by I0 (Priest) on Jan 05, 2001 at 04:38 UTC | |
by coreolyn (Parson) on Jan 05, 2001 at 05:53 UTC | |
|
Re: while 's 'continue' block
by Hot Pastrami (Monk) on Jan 04, 2001 at 21:35 UTC |