Skip to content

Instantly share code, notes, and snippets.

@dora-gt
Created November 5, 2011 13:49
Show Gist options
  • Save dora-gt/1341517 to your computer and use it in GitHub Desktop.
Save dora-gt/1341517 to your computer and use it in GitHub Desktop.
-> is omittable in Perl in some situations

The output may be like this:

value_2_1
value_2_1

It is because -> is omittable when it's between [ ] or { }.

#! /usr/bin/perl
my %hash_1 = (
attr1 => "value1",
attr2 => {attr_2_1 => "value_2_1", attr_2_2 => "value_2_2"},
);
print $hash_1{attr2}->{attr_2_1} . "\n";
print $hash_1{attr2}{attr_2_1} . "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment