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

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Can sub return more then one value?



May 3, 2017, 1:16 PM

Post #1 of 3 (1576 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?


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

Veteran / Moderator

May 3, 2017, 2:25 PM

Post #2 of 3 (1564 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.

return $var1, $var2, $var3;

my @list_of_values = my_subroutine();


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



Veteran / Moderator

May 3, 2017, 3:06 PM

Post #3 of 3 (1560 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