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:
Can sub return more then one value?

 



digioleg54
User

May 3, 2017, 1:16 PM

Post #1 of 3 (563 views)
Can sub return more then one value? Can't Post

Can the sub return one, two or even more values and how? How can I catch values in the main program?

Thanks


(This post was edited by digioleg54 on May 3, 2017, 1:21 PM)


FishMonger
Veteran / Moderator

May 3, 2017, 2:25 PM

Post #2 of 3 (551 views)
Re: [digioleg54] Can sub return more then one value? [In reply to] Can't Post

Yes, a sub can return a list of values.

Code
return $var1, $var2, $var3;



Code
my @list_of_values = my_subroutine();

or

Code
my ($v1, $v2, $v3) = my_subroutine();


Code



      
    


Laurent_R
Veteran / Moderator

May 3, 2017, 3:06 PM

Post #3 of 3 (547 views)
Re: [digioleg54] Can sub return more then one value? [In reply to] Can't Post

Dear digioleg54,
I am sure happy to answer your questions. But I have the feeling that in many cases, you don't do your homework before asking. Maybe you should make an effort trying to find the answer before asking.

Or, rather, maybe you should take the time to read a good tutorial on Perl before asking any question. Or even an introductory book on Perl. I'm pretty sure you'll save quite a bit of time reading a good introduction to Perl, rather than just asking basic questions on this forum.

Please make some effort trying to understand Perl with the right tutorial or book, then your questions will be hopefully more precise and more pointed, and we will be able and have the pleasure to provide better answers.

 
 


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

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