in reply to passing @ to sub and getting back hash

You're not returning anything.

put return %enc at the end of your sub.