Re: Problem with my code

Chas Owens wrote:
The use of the special variable $; is not why
$foo{$a[1],$a[2],$a[3],$a[4]} is a bad choice; it is a bad choice
because it is hard to tell if they meant to use
@foo{$a[1],$a[2],$a[3],$a[4]} but screwed up the sigil. The spaces
are only important if you want to recover the individual values from
the key, and, since you are storing the entire record, you don't even
need the key to get those values. Why would you create a nested hash?
This does not appear to be a tree data. If you want to do it long
hand because you don't want the spaces that using an array slice will
add then simply say



use strict;
use warnings;

use Data::Dumper;

my %hash1 = ();
my %hash2 = ();

my $key1 = 'ab';
my $key2 = 'c';
$hash1{"$key1$key2"} = 'some value';
$hash2{$key1}{$key2} = 'some value';
print "\%hash1 = ", Dumper \%hash1;
print "\%hash2 = ", Dumper \%hash2;

my $key3 = 'a';
my $key4 = 'bc';
$hash1{"$key3$key4"} = 'some other value';
$hash2{$key3}{$key4} = 'some other value';
print "\%hash1 = ", Dumper \%hash1;
print "\%hash2 = ", Dumper \%hash2;


Just my 0.00000002 million dollars worth,

"For the things we have to learn before we can do them, we learn by doing them."