in reply to Treating sub output as a hash

You can return a reference to a hash (return \%a), and then use it as print keys %{ a() };