return wantarray ? @arr : $arr[-1]; #### return @arr[0..$#arr]; #### my ($x) = foo(...); #### sub get_headers { my $self = shift; my @headers = @_; my @values = @{$self->{headers}}{@headers}; return @values; } #### my ($recipient, $sender) = $obj->get_headers('to', 'from'); #### my ($recipient) = $obj->get_headers('to'); #### return wantarray ? @values : $values[0]; #### my $recipient = $obj->get_headers('to'); #### my $recipient = $obj->get_headers('to', 'from'); #### return @results if wantarray; carp("More than one value in result in scalar context") if @results > 1; return $results[0];