#!/usr/bin/perl package Instrument; use Moose; has name => ( is => 'rw', isa => 'Str' ); package Beatle; use Moose; use Moose::Util::TypeConstraints; subtype 'Instruments' => as 'ArrayRef'; coerce 'Instruments' => from 'ArrayRef' => via { [ map Instrument->new( name => $_ ), @$_ ] }; has name => ( is => 'rw', isa => 'Str' ); has instruments => ( is => 'rw', isa => 'Instruments', coerce => 1 ); sub plays { map $_->name, @{ shift->instruments } } package main; use XML::Simple; my $xml = XMLin( \*DATA, KeyAttr => [] ); for (@{ $xml->{beatle} }) { my $beatle = Beatle->new( %$_ ); print $beatle->name, ":\n"; print "\t$_\n" for $beatle->plays; } __DATA__ Voice Bass Guitar Piano Voice Guitar Rhodes Voice Guitar Sitar Voice Drums Percussion