From: Gurusamy Sarathy Date: Thu, 25 Mar 1999 10:33:18 +0000 (+0000) Subject: describe current behavior on local($foo{nothere}) (suggested by X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7185e5cc30e619cebead08968623dc42feff8b7e;p=p5sagit%2Fp5-mst-13.2.git describe current behavior on local($foo{nothere}) (suggested by Lionel Cons ) p4raw-id: //depot/perl@3166 --- diff --git a/pod/perlsub.pod b/pod/perlsub.pod index 3a53573..bfab0fe 100644 --- a/pod/perlsub.pod +++ b/pod/perlsub.pod @@ -581,6 +581,28 @@ Perl will print This is a test only a test. The array has 6 elements: 0, 1, 2, undef, undef, 5 +Note also that when you Cize a member of a composite type that +B, the value is treated as though it were +in an lvalue context, i.e., it is first created and then Cized. +The consequence of this is that the hash or array is in fact permanently +modified. For instance, if you say + + %hash = ( 'This' => 'is', 'a' => 'test' ); + @ary = ( 0..5 ); + { + local($ary[8]) = 0; + local($hash{'b'}) = 'whatever'; + } + printf "%%hash has now %d keys, \@ary %d elements.\n", + scalar(keys(%hash)), scalar(@ary); + +Perl will print + + %hash has now 3 keys, @ary 9 elements. + +The above behavior of local() on non-existent members of composite +types is subject to change in future. + =head2 Passing Symbol Table Entries (typeglobs) [Note: The mechanism described in this section was originally the only