in reply to Re^4: blocks and using braces around filehandles with print
in thread blocks and using braces around filehandles with print
A block can only be used where a statement is expected, in a control flow statement where a block is expected, or as an operand to an operator that expects a block.
Some operators that accept blocks:
do BLOCK
map BLOCK LIST
print BLOCK LIST
eval BLOCK
In your code, do would perform what you want
my $foo = do { print "hi!\n"; my $bar = 7; my $baz = 8; };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: blocks and using braces around filehandles with print
by bramble (Beadle) on Mar 17, 2008 at 03:30 UTC |