I'm a little embarrassed to ask this question, as I feel I should know the answer - however, I haven't been able to come up with a good answer (by searching or thinking) for 2 days! Please help - my mind is going...
I want to declare a hash-of-hashes, where some of the elements point to each other. Is it possible to do it in a declaration? Here is some code that makes it happen outside the declaration.
Any help is much appreciated!
Thanks
-Craig
use strict; use warnings; use Data::Dumper; 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', }, version4 => { # What if version4 is exactly the same as version3. # How do I just make version4 point to verson3? }, ); print STDERR "fields Dump1:\n", Dumper(\%fields), "\n"; $fields{version4} = $fields{version3}; print STDERR "fields Dump2:\n", Dumper(\%fields), "\n";
In reply to Creating pointers in a HoH declaration by cmv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |