summaryrefslogtreecommitdiff
path: root/pod/perlsub.pod
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@engin.umich.edu>1997-02-24 17:29:30 -0500
committerChip Salzenberg <chip@atlantic.net>1997-02-22 02:41:53 +1200
commitdfdcb7a067c15e57f49dda89180ef92cb98eb798 (patch)
tree07849571a37648c2bbb92102205cebd101167593 /pod/perlsub.pod
parent55479bb671272502420f9e5f7617b1b0be8544af (diff)
downloadperl-dfdcb7a067c15e57f49dda89180ef92cb98eb798.tar.gz
Re: Hash key created by subroutine call? (fwd)
On Mon, 24 Feb 1997 06:20:14 MST, Tom Christiansen wrote: >Considering how frequently this gets asked, how about >putting it in perlsub? > >------- start of forwarded message ------- >From: Rick Smith <ricks@sd.znet.com> >Newsgroups: comp.lang.perl.misc >Subject: Hash key created by subroutine call? >Date: Sat, 22 Feb 1997 21:47:52 -0800 I seem to be in a documental state today. p5p-msgid: <199702242229.RAA04395@aatma.engin.umich.edu>
Diffstat (limited to 'pod/perlsub.pod')
-rw-r--r--pod/perlsub.pod11
1 files changed, 9 insertions, 2 deletions
diff --git a/pod/perlsub.pod b/pod/perlsub.pod
index 347d2f8c92..a38d05be25 100644
--- a/pod/perlsub.pod
+++ b/pod/perlsub.pod
@@ -48,8 +48,15 @@ there's really no difference from the language's perspective.)
Any arguments passed to the routine come in as the array @_. Thus if you
called a function with two arguments, those would be stored in C<$_[0]>
and C<$_[1]>. The array @_ is a local array, but its values are implicit
-references (predating L<perlref>) to the actual scalar parameters. The
-return value of the subroutine is the value of the last expression
+references (predating L<perlref>) to the actual scalar parameters. What
+this means in practice is that when you explicitly modify C<$_[0]> et al.,
+you will be changing the actual arguments. As a result, all arguments
+to functions are treated as lvalues. Any hash or array elements that are
+passed to functions will get created if they do not exist (irrespective
+of whether the function does modify the contents of C<@_>). This is
+frequently a source of surprise. See L<perltrap> for an example.
+
+The return value of the subroutine is the value of the last expression
evaluated. Alternatively, a return statement may be used to specify the
returned value and exit the subroutine. If you return one or more arrays
and/or hashes, these will be flattened together into one large