Perl 中的 `->` 语法是什么意思? [英] What does the `->` syntax mean in Perl?
问题描述
chdir($g_var->{g_loc});
我在我正在使用的一些 perl 代码中发现了这一行,但我无法弄清楚 ->
的含义.我的意思是我找不到语法的含义.顺便说一下,g_loc 是文件夹的名称.我在这里错过了什么?
I found this line in some perl code I am working with and I could not figure out what the ->
means. I mean I cant find the meaning of the syntax. By the way, g_loc is the name of a folder. What am i missing here ?
附言我只有 4 天进入 perl.
P.S. i am only 4 days into perl.
推荐答案
->
正在取消引用引用.$g_var
包含对 %hash
(您可以使用 $hash{key}
访问的元素)的引用.
->
is dereferencing a reference. $g_var
contains a reference to a %hash
(elements of which you'd access using $hash{key}
).
您可以在 perlreftut
和 perlref
文档中找到有关引用的更多信息.还有关于列表列表(嵌套引用)的 perllol
.
You can find more information about references in the perlreftut
and perlref
documentation. There's also perllol
about lists-of-lists (nested references).
您可以使用 perldoc perlreftut
等打开文档
You can open the documentation using perldoc perlreftut
, etc.
这篇关于Perl 中的 `->` 语法是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!