in reply to Re: Modifying order of a hash
in thread Modifying order of a hash
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Modifying order of a hash
by monaghan (Novice) on Sep 30, 2008 at 21:58 UTC |