in reply to Treating sub output as a hash
The problem is that return %hash doesn't return a hash. It returns a list. Only when you assign that list to something hashy (a hash or an anonymous hash) can you treat it as a hash.
Improve your skills with Modern Perl: the free book.
In Section
Seekers of Perl Wisdom