in reply to Re: while(){}continue{}; Useful?
in thread while(){}continue{}; Useful?
Why? You can still declare a variable in the head-clause!
$\="\n"; while (my $x= < 1 2 3 4 >) { # using glob as iterator next if $x%2; print "$x: chacha" } continue { print "$x: rumba" } print $x;
output
1: rumba 2: chacha 2: rumba 3: rumba 4: chacha 4: rumba Use of uninitialized value $x in print at /home/lanx/tmp/continue.pl l +ine 8.
it's treating blocks consistently, which is a big plus in Perl! 8)
Cheers Rolf
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: while(){}continue{}; Useful? (Consistent!)
by BrowserUk (Patriarch) on Mar 03, 2010 at 23:41 UTC | |
by LanX (Saint) on Mar 04, 2010 at 00:24 UTC | |
by BrowserUk (Patriarch) on Mar 04, 2010 at 01:16 UTC | |
by LanX (Saint) on Mar 04, 2010 at 01:22 UTC | |
|
Re^3: while(){}continue{}; Useful? (Consistent!)
by Argel (Prior) on Mar 04, 2010 at 21:28 UTC |