diff options
author | Xavier Noria <fxn@hashref.com> | 2005-10-21 10:43:12 +0200 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2005-10-21 13:01:26 +0000 |
commit | dbb128be9d98f2152d3ce957d4c3c518a9f86260 (patch) | |
tree | ca1cf0b1f39542c5805f063712d33b23f6f11ed2 /pod/perlsub.pod | |
parent | 4d09c4dea70059a14cd5e6548ac118d2ad075dcb (diff) | |
download | perl-dbb128be9d98f2152d3ce957d4c3c518a9f86260.tar.gz |
Re: [PATCH] return values reworded in perlsub.pod
Message-Id: <1C8D7C5C-986C-4336-8C4F-8B965CE1AD17@hashref.com>
(with minor tweaks)
p4raw-id: //depot/perl@25812
Diffstat (limited to 'pod/perlsub.pod')
-rw-r--r-- | pod/perlsub.pod | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/pod/perlsub.pod b/pod/perlsub.pod index fbf27cdc82..9711ca6c0d 100644 --- a/pod/perlsub.pod +++ b/pod/perlsub.pod @@ -73,16 +73,19 @@ Assigning to the whole array C<@_> removes that aliasing, and does not update any arguments. X<subroutine, argument> X<argument> X<@_> -The return value of a subroutine is the value of the last expression -evaluated by that sub, or the empty list in the case of an empty sub. -More explicitly, a C<return> statement may be used to exit the -subroutine, optionally specifying the returned value, which will be -evaluated in the appropriate context (list, scalar, or void) depending -on the context of the subroutine call. If you specify no return value, -the subroutine returns an empty list in list context, the undefined -value in scalar context, or nothing in void context. If you return -one or more aggregates (arrays and hashes), these will be flattened -together into one large indistinguishable list. +A C<return> statement may be used to exit a subroutine, optionally +specifying the returned value, which will be evaluated in the +appropriate context (list, scalar, or void) depending on the context of +the subroutine call. If you specify no return value, the subroutine +returns an empty list in list context, the undefined value in scalar +context, or nothing in void context. If you return one or more +aggregates (arrays and hashes), these will be flattened together into +one large indistinguishable list. + +If no C<return> is found and if the last statement is an expression, its +value is returned. Otherwise, if the last statement is a control structure +like a C<foreach>, the returned value is unspecified. The empty sub +returns the empty list. X<subroutine, return value> X<return value> X<return> Perl does not have named formal parameters. In practice all you |