D
Dave Saville
Given
my @x = qw(a b c);
print "$x[2]\n";
($a, $b) = @x[1,2];
print "$a $b\n";
Gives me
c
b c
But
my %h;
$h{a} = [1,2,3];
print $h{a}[2]."\n";
my ($a, $b) = $h{a}[1,2];
print "$a $b\n";
Gives
3
Use of uninitialized value $b in concatenation (.) or string
3
I have tried all sorts of brackets braces etc. in various combinations
but I cannot get the anonymous array contained in the hash to work
like the first example. What silly thing am I missing?
TIA
my @x = qw(a b c);
print "$x[2]\n";
($a, $b) = @x[1,2];
print "$a $b\n";
Gives me
c
b c
But
my %h;
$h{a} = [1,2,3];
print $h{a}[2]."\n";
my ($a, $b) = $h{a}[1,2];
print "$a $b\n";
Gives
3
Use of uninitialized value $b in concatenation (.) or string
3
I have tried all sorts of brackets braces etc. in various combinations
but I cannot get the anonymous array contained in the hash to work
like the first example. What silly thing am I missing?
TIA