Here is the code to reproduce the problem:
sub hello { return (h => 1, n => 1); }
print join \", \", values hello();
I get the error:
You could use hash references:
sub hello { return {h => 1, n => 1}; }
print join ", ", values %{hello()};
but otherwise, no. Perl may interpret the return value of a subroutine in either scalar or list context, but there is no concept of returning a value in a hash context.
Update: this also works
sub hello { return (h => 1, n => 1); }
print join ", ", values %{{hello()}};
The inner {}
converts the output of hello()
from a list into a hash reference.
The outer %{}
dereferences the hash.
(Does %{{}}}
count as a pseudo-operator?)