Differentiating between a "scalar" and an "array" is meaningless here. When you say "return @bar" Perl flattens @bar into a list.
$foo = 3;
@bar = (1, 2, 3);
return $foo; # (3)
return @bar; # (1, 2, 3)
In a scalar context, both of these versions will return 3 (the last element in the list returned). In a list context, you get 3 or 1, 2, 3. Just returning @bar, though, is sufficient for both cases, because it's your calling code that would want to act on the results. Make sense?
If you're wanting to return a real solid array (so that you can return @foo, @bar without flattening it into one big list), you need to return references to each array.
return (\@foo, \@bar);
...
my ($fooref, $barref) = your_function();
|