in reply to When is a hashreference a subexpresion?

strictures would help pick up at least some of the problems you are having here.

Using an explicit return would help not only Perl figure out what you are doing, but may help other people (you in 6 months even) figure out what the intended behaviour of the code is.

{} can enclose a block or be a hash reference. Sometimes it's hard to tell which is intended. Perl is a good sport and will take a punt. Sometimes it fails to read your mind. Consider:

use warnings; use strict; sub x { ('a', 'b', 'c', 'd'); } sub a { { x }; } sub g { return { x }; } print a, "\n"; print g, "\n";

Prints:

abcd HASH(0x182f30c)

DWIM is Perl's answer to Gödel