I've got a short question about how Perl handles return values.
I've got a subroutine that returns multiple values, but in several cases I only need a subset of these values when calling the subroutine.
My question is: How can I specify which ones I want? Please have a look at this short example:
my $result = get_values(); sub get_values { return (“a”, “b”, “c”); }
In my testing $result always gets the value "c" (I assume because it's the last value). But is this guaranteed? Where is this documented? I didn't find anything at http://perldoc.perl.org/perlsub.html or http://perldoc.perl.org/functions/return.html and also perlmonks' search didn't help me out.
And taking this one step further: How can I get "a" and "c"? I know that I can just use three variables and ignore the second one, but I guess there's a better way to do that.
Thanks!In reply to Ignore certain return values by elTriberium
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |