From: Phil Monsen Date: Sun, 10 Jul 2011 02:15:40 +0000 (-0500) Subject: perlref: update bareword bracketing discussion, mention new auto-dereferencing X-Git-Tag: accepted/trunk/20130322.191538~3364 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=903c0e71ef4db59d59dc1e818fd65b4096c422a1;p=platform%2Fupstream%2Fperl.git perlref: update bareword bracketing discussion, mention new auto-dereferencing --- diff --git a/AUTHORS b/AUTHORS index ab608b5..b9de691 100644 --- a/AUTHORS +++ b/AUTHORS @@ -861,6 +861,7 @@ Peter Wolfe Peter E. Yee Petter Reinholdtsen Phil Lobbes +Phil Monsen Philip Hazel Philip M. Gollucci Philip Newton diff --git a/pod/perlref.pod b/pod/perlref.pod index f45a383..f1dffce 100644 --- a/pod/perlref.pod +++ b/pod/perlref.pod @@ -51,6 +51,19 @@ scalar is holding a reference, it always behaves as a simple scalar. It doesn't magically start being an array or hash or subroutine; you have to tell it explicitly to do so, by dereferencing it. +References are easy to use in Perl. There is just one overriding +principle: in general, Perl does no implicit referencing or dereferencing. +When a scalar is holding a reference, it always behaves as a simple scalar. +It doesn't magically start being an array or hash or subroutine; you have to +tell it explicitly to do so, by dereferencing it. + +That said, be aware that Perl version 5.14 introduces an exception +to the rule, for syntactic convenience. Experimental array and hash container +function behavior allows array and hash references to be handled by Perl as +if they had been explicitly syntactically dereferenced. See +L +and L for details. + =head2 Making References X X @@ -562,16 +575,16 @@ variables, which are all "global" to the package. =head2 Not-so-symbolic references -A new feature contributing to readability in perl version 5.001 is that the -brackets around a symbolic reference behave more like quotes, just as they -always have within a string. That is, +Since Perl verion 5.001, brackets around a symbolic reference can simply +serve to isolate an identifier or variable name from the rest of an +expression, just as they always have within a string. For example, $push = "pop on "; print "${push}over"; has always meant to print "pop on over", even though push is -a reserved word. This has been generalized to work the same outside -of quotes, so that +a reserved word. In 5.001, this was generalized to work the same +without the enclosing double quotes, so that print ${push} . "over"; @@ -588,9 +601,9 @@ using strict refs: ${ bareword }; # Okay, means $bareword. ${ "bareword" }; # Error, symbolic reference. -Similarly, because of all the subscripting that is done using single -words, we've applied the same rule to any bareword that is used for -subscripting a hash. So now, instead of writing +Similarly, because of all the subscripting that is done using single words, +the same rule applies to any bareword that is used for subscripting a hash. +So now, instead of writing $array{ "aaa" }{ "bbb" }{ "ccc" }