Convert objects into perl hash