use warnings; use strict; use XML::Rules; use Data::Dump; my $parser = XML::Rules->new( stripspaces => 3|4, warnoverwrite => 1, namespaces => { 'http://www.example.com/foo' => '', 'http://www.example.com/bar' => '', '*' => 'die' }, # don't allow other namespaces rules => [ 'Height|Length|Width|Weight' => sub { lc $_[0] => $_[1]->{_content} }, 'root' => 'pass', _default => sub { die "Unknown tag $_[0]" }, ] ); dd $parser->parse(<<'END_XML'); 1.00 1.00 1.00 0.01 END_XML __END__ { height => "1.00", length => "1.00", weight => 0.01, width => "1.00" }