CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Alternate way of returning value

 



tharpa
Novice

Jul 19, 2016, 8:19 AM

Post #1 of 3 (1626 views)
Alternate way of returning value Can't Post

I am maintaining a venerable old program. There is a method that contains a line,

Code
$status = $self->uncompress_files($archive);


I would have expected that the method uncompress_files() would contain a return statement something like

Code
return value;

, but it does not. uncompress_files() ends with the line

Code
$self->uncompress(\@process_files, $archive);

. How is it returning a value to its caller?


FishMonger
Veteran / Moderator

Jul 19, 2016, 8:54 AM

Post #2 of 3 (1625 views)
Re: [tharpa] Alternate way of returning value [In reply to] Can't Post


Code
C:\>perldoc -f return 
return EXPR
return Returns from a subroutine, "eval", or "do FILE" with the value
given in EXPR. Evaluation of EXPR may be in list, scalar, or
void context, depending on how the return value will be used,
and the context may vary from one execution to the next (see
"wantarray"). If no EXPR is given, returns an empty list in list
context, the undefined value in scalar context, and (of course)
nothing at all in void context.

(In the absence of an explicit "return", a subroutine, eval, or
do FILE automatically returns the value of the last expression
evaluated.)


Unlike most named operators, this is also exempt from the
looks-like-a-function rule, so "return ("foo")."bar"" will cause
"bar" to be part of the argument to "return".



tharpa
Novice

Jul 19, 2016, 8:57 AM

Post #3 of 3 (1623 views)
Re: [FishMonger] Alternate way of returning value [In reply to] Can't Post

Thanks.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives