Why do all of these methods of accessing an array work?

Posted by bstullkid on Stack Overflow See other posts from Stack Overflow or by bstullkid
Published on 2010-05-19T19:35:46Z Indexed on 2010/05/19 19:40 UTC
Read the original article Hit count: 209

Filed under:
|
|

It seems to me that some of these should fail, but they all output what they are supposed to:

$, = "\n";
%test = (
    "one" => ["one_0", "one_1"],
    "two" => ["two_0", "two_1"]
);

print @{$test{"one"}}[0],
      @{$test{"one"}}->[0],
      $test{"two"}->[0],
      $test{"one"}[1];

Why is this?

© Stack Overflow or respective owner

Related posts about perl

Related posts about hash