Problem with syntax getting array elements



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
--
Regards
Dave Saville
.



Relevant Pages

  • Re: construction of coproduct of monoids?
    ... I can readily see that it is a monoid. ... concatenation: if m0*m1 is the identity, ... I think you are missing the point. ... The question is not about proving ...
    (sci.math)
  • Re: Number of Triangles from given set of rods
    ... a concatenation does not matter). ... If the k were not missing, the same argument would show that one can ... If one ignores this defect, one can obtain *all* triangles ... smallest sides c and in fact pose a problem only if c=k. ...
    (sci.math)
  • Re: strings combine
    ... but string literal "implicit" concatenation has always been ... a feature. ... Yeah--for me it has almost always represented a bug (like a missing, ...
    (comp.lang.ruby)
  • Re: Help.............
    ... but if you want a simple concatenation of the two files, ... > me in writing a code so that the data in book.txt & authour.txt clubs and ... > TIA ... Prev by Date: ...
    (microsoft.public.vb.com)
  • Re: Sunday Times Cryptic 4230 - summat missing?
    ... something missing from ... ... that the def part is somewhat vague -- and I totally agree about the ... Tristram" as the definition? ... I'm sure that's the intent but "A of B" doesn't suggest the concatenation. ...
    (rec.puzzles.crosswords)