Convert objects to perl hash