in reply to statement vs. block?
Something like this?
Here, all loop constructs introduces a scope for the expression just as they would if it was a block. if however doesn't.our ($For, $While, $Map, $Grep, $If) = qw( For While Map Grep If) ; local $For = 'local' for 1; local $While = 'local' while ! $a++; map +(local $Map = 'local'), 1; grep +(local $Grep = 'local'), 1; local $If = 'local' if 1; print "For: $For\n"; print "While: $While\n"; print "Map: $Map\n"; print "Grep: $Grep\n"; print "If: $If\n"; __END__ For: For While: While Map: Map Grep: Grep If: local
While speaking about blocks for map and grep (and sort):
fails with '"use" not allowed in expression ...'. A do block can be used tomap { use strict; } LIST
works. (Interestingly, this uses map EXPR, LIST ...)map do { use strict; }, LIST
lodin
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: statement vs. block?
by ysth (Canon) on Apr 13, 2008 at 04:59 UTC | |
|
Re^2: statement vs. block?
by ikegami (Patriarch) on Apr 13, 2008 at 05:28 UTC |