in reply to Re: Add attribute to xml with XML::LibXML
in thread Add attribute to xml with XML::LibXML

FYI, if your version of XML::LibXML is vaguely recent (since 1.9x), then this:

$node->setAttribute( 'type', $newtypes{$node->getAttribute('name')} );

Can be written as:

$node->{type} = $newtypes{ $node->{name} };

That is, XML::LibXML::Element acts like a hashref, and you can get/set attributes that way.

package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name