Or, just to keep it simple, and more like what was requested originally (as there may be something else that we don't know about, that would have problems if it were a deep structure), you can use a flat hash:
my %data; $data{'exampleother1'} = 'something'; $data{'exampleother2'} = 'something else'; $data{$var1.$var2.$number} = $value; # or using a hashref my $data; $data->{'exampleother1'} = 'something'; $data->{'exampleother2'} = 'something else'; $data->{$var1.$var2.$number} = $value;
The deeper structure has advantages if you might have values for ($var1.$var2) that collide. (if those should be two discrete values, then use a hash of hashes or some other complex structure. If they should be the same value, then just use a single dimensional hash).
In reply to Re^2: Dynamically Building Variable Names
by jhourcle
in thread Dynamically Building Variable Names
by willyyam
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |