->是什么?在Perl中做箭头? [英] What does the -> arrow do in Perl?

查看:89
本文介绍了->是什么?在Perl中做箭头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在代码中看到->,但我不确定这是什么意思.例如:

I keep seeing -> in code and I am not exactly sure what it means. For example:

@top_links = @{$m->links};

这行是做什么的?另外,我在哪里可以读到它?

What does this line do? Also, where can I maybe read about it?

推荐答案

请参见箭头运算符:

就像在C和C ++中一样,

"->"是一个中缀取消引用运算符.如果右侧是[...]{...}(...)下标,则左侧必须分别是对数组,哈希或子例程的硬引用或符号引用. (或者从技术上讲,如果是用于分配的数组或哈希引用,则该位置能够保留硬引用.)请参见 perlref .

"->" is an infix dereference operator, just as it is in C and C++. If the right side is either a [...], {...}, or a (...) subscript, then the left side must be either a hard or symbolic reference to an array, a hash, or a subroutine respectively. (Or technically speaking, a location capable of holding a hard reference, if it's an array or hash reference being used for assignment.) See perlreftut and perlref.

否则,右侧是方法名称或包含方法名称或子例程引用的简单标量变量,左侧必须是对象(祝福的引用)或类名称(即,包裹名字).参见 perlobj .

Otherwise, the right side is a method name or a simple scalar variable containing either the method name or a subroutine reference, and the left side must be either an object (a blessed reference) or a class name (that is, a package name). See perlobj.

这篇关于->是什么?在Perl中做箭头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆