in reply to printing CSV to file?

I think that one problem with your code is that you really want:
foreach my $hash (keys %hashed) { ...
From your brief description im assuming that you want $hash to iterate over the keys in the hash, not both the keys and the values.