Here is the code to reproduce the problem:
sub hello { return (h => 1, n => 1); }
print join ", ", values hello();
I get the error:
Type of arg 1 to values must be hash
(not subroutine entry) at – line 4,
near “);” Execution of – aborted due
to compilation errors.
I know I can break the call and the print on two lines:
sub hello { return (h => 1, n => 1); }
my %hash = hello();
print join ", ", values %hash;
But I don’t want to do that. Is there some way to do this in one line so that I don’t have to create temporary variables all the time?
I don’t see the usefulness in a real program, but yes, it is possible.
Explanation:
hello()is a list;{hello()}is a hash reference;%{{hello()}}is a hash.