in reply to Re: Modifying order of a hash
in thread Modifying order of a hash

This will do the job:
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:

my %newhash = map { $_ => { map { delete $_->{COMP} => $_ } @{$hash{$_}} } } keys %hash;
Best regards

Replies are listed 'Best First'.
Re^3: Modifying order of a hash
by monaghan (Novice) on Sep 30, 2008 at 21:58 UTC
    This works great and I appreciate all of your help. I'm not that familiar with the map function but it has worked for me well so far. I'm now trying to incorporate multiple hashes rather than above where I have just one and it doesn't seem to work. I've wrapped a foreach statement around the code but would that mess up the map function?