in reply to Re^3: "when" and replacements
in thread "when" and replacements
Yeah sounds like perfect orthogonal design. Though one has to keep in mind that leaving the block demands different statements.
use feature qw(switch); given (1) { print; break; print } for (1) { print; last; print }
Cheers Rolf
UPDATE:
confusingly this works well:
$\="\n"; for ("012") { if (/0/) {print "0 matched"}; # prints 0 when (/1/) {print "1 matched"}; # prints 1 when (/2/) {print "2 matched"}; # nix if (/3/) {print "3 matched"}; # nada }
but the perlsyn says Every "when" block is implicitly ended with a "break".
Consequently "break" should also leave loop-blocks, or the documentation should be updated.
IMHO break is needless and should be abandoned in favor of last. (which linguistically still makes sense)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: "when" and replacements
by JavaFan (Canon) on May 07, 2011 at 12:01 UTC | |
by LanX (Saint) on May 07, 2011 at 12:11 UTC | |
by JavaFan (Canon) on May 07, 2011 at 13:57 UTC | |
by LanX (Saint) on May 07, 2011 at 14:28 UTC |