We're migrating incrementally, for various reasons (the systems are mission-critical, most importantly), and hence it's important that scripts and systems that already exist can interface, short-term, with the new code and systems put in.
To cope with the new client identifiers, I've created a hash that contains data for each client keyed on the new, 7-character, identifier, which was simple enough to do.
What I now need to do is find a way of having the old-style identifiers reference the new ones, so a call to, for example, $clients{ABCD} actually uses (and potentially modifies) the data in $clients{ABCDEFG}, rather than having to store the data twice and subsequently modify the data twice.
I've tried to do this using references, with the code below:
but this doesn't work - some of the new keys are "displaced" by the old keys, and some of the keys are simply left referencing an empty hash.my %new_client_hash; foreach my $old_key (keys %clients) { my $new_key = $clients{$old_key}{new_sys_id}; delete $clients{$old_key}{new_sys_id}; $new_client_hash{$new_key} = $clients{$old_key}; $new_client_hash{$old_key} = \$new_client_hash{$new_key}; }
Does anyone know of a way to achieve this, or am I missing something obvious in the code there?
Any help would be appreciated.
Thanks,
-- Foxcub
In reply to Multiple keys describing a single hash element by Tanalis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |