$VAR1 = { 'requirement' => [ { 'contactname' => 'Joe Average', 'content' => 'A power cord.' }, { 'contactnumber' => '555-1212', 'contactname' => 'Jane Smith', 'content' => 'A node name' } ] }; #### use strict; use XML::Simple; my $data = do {local $/;}; my $xml = XMLin($data,forcearray=>1); my $new; for my $req (@{$xml->{requirement}}) { my %temp; $temp{text} = delete $req->{content}; $temp{attributes} = [%$req]; push @{$new->{requirements}}, {%temp}; } __DATA__ A power cord. A node name #### $VAR1 = { 'requirements' => [ { 'text' => 'A power cord.', 'attributes' => [ 'contactname', 'Joe Average' ] }, { 'text' => 'A node name', 'attributes' => [ 'contactnumber', '555-1212', 'contactname', 'Jane Smith' ] } ] }; #### $VAR1 = { 'method' => [ { 'object' => [ 'Properties', 'Do not use option Foo', 'Server Name', 'OK' ], 'content' => [ 'Open up the ', ' page. Then uncheck the ', ' checkbox. Under ', ' enter ', ' and then hit ' ], 'input' => [ 'www.example.com' ] } ] };