diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-03-25 10:33:18 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-03-25 10:33:18 +0000 |
commit | 7185e5cc30e619cebead08968623dc42feff8b7e (patch) | |
tree | ddc90075c373009c9fcb149230296f553d288a6f /pod/perlsub.pod | |
parent | 358b5eb8e3f1439968234b2c14fbc5167287307f (diff) | |
download | perl-7185e5cc30e619cebead08968623dc42feff8b7e.tar.gz |
describe current behavior on local($foo{nothere}) (suggested by
Lionel Cons <lionel.cons@cern.ch>)
p4raw-id: //depot/perl@3166
Diffstat (limited to 'pod/perlsub.pod')
-rw-r--r-- | pod/perlsub.pod | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/pod/perlsub.pod b/pod/perlsub.pod index 3a5357392c..bfab0fe81e 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 C<local>ize a member of a composite type that +B<does not exist previously>, the value is treated as though it were +in an lvalue context, i.e., it is first created and then C<local>ized. +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 |