2009/11/12 Peter Scott <pe...@psdt.com>: > On Thu, 12 Nov 2009 09:55:39 +0000, Philip Potter wrote: >> 2009/11/11 Shawn H Corey <shawnhco...@gmail.com>: >>> no warnings 'once'; >>> my @aoh = pairwise { +{ %{$a}, %{$b} } } @aoh_a, @aoh_b; >> >> Thanks for your response. What are the grammar rules here? Why must I >> use an explicit return or unary + operator? Why is it not being >> interpreted as an anonymous array? > > Because otherwise it's interpreted as a naked block.
My question runs deeper than this. What are the criteria? When are curlies a bare block and when are they an anonymous hash? What are the grammar rules? How could I have known a priori to put a "return" or "+" in? The camel book page 247 says "you may occasionally have to disambiguate braces at the beginning of a statement by putting a + or return in front" but doesn't go on to explain *when* those occasions are. This contrasts with the plans for Perl 6, where it's very easy to define what's a block and what's a hashref: http://svn.pugscode.org/pugs/docs/Perl6/Spec/S06-routines.pod "C<{...}> is always a block. However, if it is completely empty or consists of a single list, the first element of which is either a hash or a pair, it is executed immediately to compose a C<Hash> object." What is the equivalent rule for Perl 5? Is it "If it can be interpreted as a block, it is"? Phil -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/