From: why the lucky stiff Date: 2002-12-12T08:56:07+09:00 Subject: Re: calling a perl script (YAML serialization?) On Wednesday 11 December 2002 01:01 pm, Phil Tomson wrote: > Now here's a crazy idea: What we had some sort of Inline::Perl that used > YAML serialization to communicate between the two sides? There are YAML > serialization modules for both Ruby and Perl and they could be used to > pass objects back and forth between the two languages. An Inline::Perl > module would just sort of make the underlying communication between the > two transparent. Certainly most of the builtin types like Arrays, Hashes, > String and FixNums would be transportable, I'm not sure how user defined > classes would transfer, however (YAML dudes: is this feasable?) Oh, yes. It's the essence of YAML's existence. User-defined classes are merely native types that are explicitly typed in YAML. So this is a Ruby Hash in YAML: name: Peter Gorley id: 345 email: peter.gorley@yaml.org Perl would also load the above as a hash. But if you suddenly wanted to use Ruby classes, the Hash would become typed: --- !!employee name: Peter Gorley id: 345 email: peter.gorley@yaml.org You would then write handler code to load this YAML document as a class in YAML.rb: YAML::add_private_type( 'employee' ) { |type, val| YAML::object_maker( EmployeeClass, val ) } This is just one technique, though. There are several. I'd check out the Cookbook [http://yaml4r.sf.net/cookbook/] and the YAML.rb docs [http://yaml4r.sf.net/doc/] for more ideas. _why