use XML::Smart ; my $xml = new XML::Smart() ; $xml->{phone} = '555-1234' ; $xml->{phone}{type} = 'home' ; print $xml->data ;