Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Creating pointers in a HoH declaration

by graff (Chancellor)
on Apr 30, 2016 at 16:11 UTC ( #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
Node Status?
node history
Node Type: note [id://1161958]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2021-03-01 16:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (13 votes). Check out past polls.

    Notices?