Your big picture problem is that you need to serialize your data before passing it along -- sockets know only a series of bits, not data structures. As suggested before, YAML is an excellent choice for most uses. Perhaps the more traditional method is Storable, but there are plenty of choices available.