summaryrefslogtreecommitdiff
path: root/pod/perltrap.pod
diff options
context:
space:
mode:
authorRobin Barker <RMBarker@cpan.org>2001-11-15 13:48:34 +0000
committerAbhijit Menon-Sen <ams@wiw.org>2001-11-15 12:56:49 +0000
commitbf1f881789eedea18ed5f17829aaa1c73d7cf6f7 (patch)
tree48de962927a9dea3ef5f44df43664939bc2c6e5d /pod/perltrap.pod
parent9a1f07e743e42a0b7bb5626198fd8bf95eba6fbc (diff)
downloadperl-bf1f881789eedea18ed5f17829aaa1c73d7cf6f7.tar.gz
Re: Strange syntax error with map
Message-Id: <200111151348.NAA01299@tempest.npl.co.uk> (Applied with tweaks.) p4raw-id: //depot/perl@13017
Diffstat (limited to 'pod/perltrap.pod')
-rw-r--r--pod/perltrap.pod10
1 files changed, 10 insertions, 0 deletions
diff --git a/pod/perltrap.pod b/pod/perltrap.pod
index 262937910d..831d2d5402 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<map {> (or C<grep {>), 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<perlfunc/map>.)
+
=back
=head2 Numerical Traps