From: Brian Candler Date: 2003-05-15T17:59:22+09:00 Subject: Re: Marshal string format On Thu, May 15, 2003 at 09:32:54AM +0900, Pablo Lorenzzoni wrote: > Given a class (let's take the Pickaxe example) > > class Klass > def initialize(str) > @str=str > end > def sayHello > @str > end > end > > o=Klass.new("hello\n") > data=Marshal.dump(o) > > p data => "\004\006o:\nKlass\006:\t@str\"\nhello" > > What does all the meta-data in string "data" mean? Have a look through marshal.c, it's very clearly written. Marshal is intended to be an 'opaque' string that you can squirt into a file or down a wire, and recreate a copy of the same object at the other end. If you want it to be parseable, you might prefer to use a different marshaling library (e.g. YAML or SOAP). Or you can extract the data about your object directly: p o.class p o.instance_variables o.instance_variables.each { |v| p o.instance_variable_get(v) } # 1.8 only Marshal is very, very fast though. I would love to see a C library for Perl which reads/writes in Ruby's Marshal format :-) Cheers, Brian.