in reply to creating multiple views of a hash by reordering its key and values
You could just add the new keys to the existing hash and make the same data serve both sets of keys:
I won't vouch for the purity of design, but it ought to be efficient, giving two views of the identical data. Updates from one view will be seen from the other.foreach my $user (keys %dateuserfile) { for (keys %{$dateuserfile{$user}}) { $dateuserfile{$_}{$user} = $dateuserfile{$user}{$_}; } }
Update: ichimunki, rewrite line 5 as $hash{bar}{foo} = $hash{foo}{bar};. You're copying the value by including the deepest key. Leave off that last key and you get a copy ot the reference to the hash where it lives.
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(ichi) Re x 2: creating multiple views of a hash by reordering its key and values
by ichimunki (Priest) on Jun 26, 2002 at 17:30 UTC |