use strict; use Data::DumpXML qw(dump_xml); my $foo = Foo->new(); dump_xml($foo); package Foo; sub new { return bless { scalar => 'foobar', array => [('a'..'d')], hash => { bar => { baz => 'qux'}}, }, shift; }