Suppose you have this code:
my %hash = (
a => 1,
b => 2,
c => 3,
d => 4
my $n = ($_) ? $_ : keys %hash;
return (keys %hash)[0 .. ($n - 1)]; # return %hash keys from 0 to $n
+ - 1
my $bar = &foo(); # want to return the number of keys of %hash
You'll notice that the value printed isn't the num of keys
but a key itself.
(Suppose the code from the beginning to end of foo function
is located in an external package!!)
But foo return a list; the value returned by foo is evaluated
in an array context and so 'Why does not it work?'