开发者

Is dl_load_file called or not here?

开发者 https://www.devze.com 2023-03-20 06:43 出处:网络
unless defined(&dl_load_fi开发者_StackOverflow社区le); The above looks ambiguous to me but actually works .
unless defined(&dl_load_fi开发者_StackOverflow社区le);

The above looks ambiguous to me but actually works .

How does Perl know whether or not to call dl_load_file here?


It's just a special case in Perl's syntax. If you have either defined(&identifier) or defined &identifier, it checks for the existence of a subroutine named identifier without calling it, even though &identifier would normally call the subroutine.

defined &identifier(), on the other hand, does call the subroutine and then test its return value. The parens after identifier make it a function call.


I think there is not a call - is just a check to see if that function is defined or not

Perl interpreter knows this with the help of Symbol Tables

0

精彩评论

暂无评论...
验证码 换一张
取 消