What should I do to prevent Perl from complaining that "using the hash as a link is out of date"?

Below is the code from the old Perl script.

print "%{@{$noss}[$i]}->{$sector} \n\n";

How can I rewrite the above code so that Perl does not complain that "using the hash as a link is out of date"? I tried all sorts of ways, but I still could not fully understand what the Perl compiler wants me to do.

+3
source share
3 answers
print "%{@{$noss}[$i]}->{$sector} \n\n";

should be no more than

print "$noss->[$i]{$sector} \n\n";

or even

print "$$noss[$i]{$sector} \n\n";

without all this rigamarole.

+10
source

, $noss -, , ( $/@/%) , .

, , $foo[$i], ${$noss}[$i]. hashref, $foo{$sector} ${ ${$noss}[$i] }{$sector}.

, $noss->[$i]{$sector}; . http://perlmonks.org?node=References+quick+reference .

+5

ysth tchrist , $noss->[$i]{$sector} . , , $noss $i - $sector .

In terms of teaching fish, not distributing fish: you should read perldoc perlreftutand, in particular, the “rules of use”. Understanding these two “rules of use” along with the additional “arrow rule” (only three rules) will give you a much better idea of ​​how to go with links.

+4
source

All Articles