Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

drhyde (1683)

drhyde
  (email not shown publicly)
http://www.cantrell.org.uk/david

Journal of drhyde (1683)

Thursday January 29, 2004
06:20 PM

slices of references

[ #17095 ]
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?

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • What you want is:
    $h = {a => 'b', c => 'd'};
    print @{$h}{qw(a c)}
    --

    --
    "Cake or Death!" .... "Cake please"
    • Re:Close... (Score:3, Informative)

      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'}