Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Creating pointers in a HoH declaration

by graff (Chancellor)
on Apr 30, 2016 at 16:11 UTC ( [id://1161958]=note: print w/replies, xml ) Need Help??


in reply to Creating pointers in a HoH declaration

I'm afraid I don't see any compelling reason to do this sort of thing in a single initialization step. You're just doing an initialization; you already know, in advance of writing the code, that you need multiple hash keys that point to the same data, and I gather you've already established that the "normal" way of doing this does what you intend, so it would seem clearer, cleaner, and more maintainable to be explicit about how the initialization is done:
my %fields = ( version1 => { 1 => 'Field 1', 2 => 'Field 2', 3 => 'Field 3', }, version2 => { 1 => 'Field 1', 2 => 'Field 2', 3 => 'Field 3', 4 => 'Field 4', }, version3 => { 1 => 'Field 1', 2 => 'Field 2', 3 => 'Field 3', 4 => 'Field 4', 5 => 'Field 5', }, ); my %synonyms = ( version4 => 'version3', # ... maybe you want others? ... ); $fields{$_} = $fields{ $synonyms{$_} } for ( keys %synonyms );

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1161958]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2024-04-19 15:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found