From: Robin Barker Date: Thu, 15 Nov 2001 13:48:34 +0000 (+0000) Subject: Re: Strange syntax error with map X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bf1f881789eedea18ed5f17829aaa1c73d7cf6f7;p=p5sagit%2Fp5-mst-13.2.git Re: Strange syntax error with map Message-Id: <200111151348.NAA01299@tempest.npl.co.uk> (Applied with tweaks.) p4raw-id: //depot/perl@13017 --- diff --git a/pod/perltrap.pod b/pod/perltrap.pod index 2629379..831d2d5 100644 --- a/pod/perltrap.pod +++ b/pod/perltrap.pod @@ -651,6 +651,16 @@ are to used around the name. # perl4 prints: {a} # perl5 prints: 2 +=item * Parsing + +When perl sees C (or C), it has to guess whether the C<{> +starts a BLOCK or a hash reference. If it guesses wrong, it will report +a syntax error near the C<}> and the missing (or unexpected) comma. + +Use unary C<+> before C<{> on a hash reference, and unary C<+> applied +to the first thing in a BLOCK (after C<{>), for perl to guess right all +the time. (See L.) + =back =head2 Numerical Traps