in reply to how to assign a hash to a file

Note that
%hash = { ... };
should be
%hash = ( ... );
The curlies create an anonymous hash and return a reference to that hash. However, when you assign to a hash, you want to assign a list of key/values, not a reference to another hash. svenXY silently fixed this in his reply, but I thought it was worth mentioning.