my %newhash = map { $_ => [ map { { delete $_->{COMP} => $_ } } @{$hash{$_}} ] } keys %hash;
EDIT:
Or may be :
my %newhash = map { $_ => [{ map { delete $_->{COMP} => $_ } @{$hash{$_}} }] } keys %hash;
depending on what you want as final result: your example is vague because you have only one element in the inner array reference
If it was my program I will be looking for result like:
{ '103496-1' => { '1234' => { 'FD' => '0010', 'CLVD' => '5678', 'Files' => [ { 'hash' => 'a538346ad3485', 'File' => 'text.txt' }, { 'hash' => '237d97892376a', 'File' => 'text2.txt' } ] } } };
because you do not need an arrayref with just one element - hash reference. In which case use the following:
Best regardsmy %newhash = map { $_ => { map { delete $_->{COMP} => $_ } @{$hash{$_}} } } keys %hash;
In reply to Re^2: Modifying order of a hash
by karavelov
in thread Modifying order of a hash
by monaghan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |