Why doesn't this work?
$ perl -le'do { print $i++; last if $i>5 } while 1; print "end"'
0
1
2
3
4
5
Can't "last" outside a loop block at -e line 1.
while (no pun intended) this works:
$ perl -le'while (1) { print $i++; last if $i>5 } print "end"'
0
1
2
3
4
5
end
Isn't do {} while as much a loop as while () {}?
In reply to last in do vs last in while/for by dgaramond2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |