且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

perl中的& function和function()之间的区别

更新时间:2023-12-04 11:23:04

它具有非常特殊的用途:

It has very specific uses:

  • &告诉Perl忽略潜艇的原型.
  • &可以允许您使用呼叫者的@_. (&foo;,没有任何括号或参数).
  • goto &foo;defined &foo.
  • 获取参考(例如\&foo).
  • & tells Perl to ignore the sub's prototype.
  • & can allow you to use the caller's @_. (&foo; with no parens or arguments).
  • goto &foo; and defined &foo.
  • Getting a reference (e.g. \&foo).

由于内置函数不能以&开头,因此某些人(大多数是初学者)使用它来区分用户子对象和内置函数.

Some people (mostly beginners) use it to distinguish user subs from builtin functions, since builtin functions cannot be preceded by &.