slices of references

drhyde on 2004-01-29T23:20:00

is there any good reason why this:

$h = {a => 'b', c => 'd'};
print @h->{a,c}


doesn't show me the values for the 'a' and 'c' keys?


Close...

triv on 2004-01-29T23:51:30

What you want is:
$h = {a => 'b', c => 'd'};
print @{$h}{qw(a c)}

Re:Close...

TorgoX on 2004-01-30T02:45:55

As to a good reason, I think there's a sort of precedence to @... versus ...-> that means that @h->... would parse as (@h)->...

So one has to do @$h{'a','c'}