1
open PROPS, $propertyFile or die "Cannot open $propertyFile";
while ( my $lines = <PROPS> ) {
    chop $line;
    my @fields = split(/,/, $line)
    $r_CntrProp->{$fields[0]}->{$fields[1]} = {
        'behaviour'  => $fields[2],
        'type'       => $fields[3],
        'compressed' => $fields[4]
    };
}

propertyFile is being read as input file from user.

GMB
  • 216,147
  • 25
  • 84
  • 135
Meenakshi
  • 51
  • 2
  • Where in that code is `-->` ? I only see `->`, which is used to access the stuff that a reference points to. Please [edit] your question and either correct the title or paste the code that contains `-->`. – Corion Dec 27 '18 at 13:25
  • @Corion i rectified my mistake – Meenakshi Dec 27 '18 at 13:33
  • Check references, https://perldoc.perl.org/perlreftut.html – mpapec Dec 27 '18 at 13:47
  • `-->` [is the "goes to" operator](https://stackoverflow.com/questions/1642028/what-is-the-operator-in-c) – mob Dec 27 '18 at 17:09
  • http://perlmonks.org?node=References+quick+reference – ysth Dec 27 '18 at 20:54
  • `EXPR1->{EXPR2}` is a hash element dereference. It gets the element with key `EXPR2` from the hash referenced by `EXPR1`. – ikegami Dec 28 '18 at 23:21

1 Answers1

3

$r_CntrProp->{$fields[0]}->{$fields[1]}

In this piece of code, for each arrow (->) :

  • the left side is a hash reference
  • the right side, enclosed between {}, is a hash key

The expression gives access to whatever is stored under the key within the hash reference. Your code actually assigns something to that hash entry (a hash reference).

See The Arrow Operator in perlop and Using References in perlref.

Basically, $r_CntrProp is a reference to a hash of hash references, like :

my $r_CntrProp  = {
    foo => {
        bar => 'baz'
    }
};

print $r_CntrProp->{foo}->{bar}, "\n";

Yields :

baz
GMB
  • 216,147
  • 25
  • 84
  • 135