csdnceshi62 2010-12-30 14:42 采纳率: 100%
浏览 312
已采纳

在 Perl 中@的意思是什么?

What is the meaning of @_ in Perl?

转载于:https://stackoverflow.com/questions/4563485/what-is-the-meaning-of-in-perl

  • 写回答

9条回答 默认 最新

  • 旧行李 2010-12-30 14:47
    关注

    perldoc perlvar is the first place to check for any special-named Perl variable info.

    Quoting:

    @_: Within a subroutine the array @_ contains the parameters passed to that subroutine.

    More details can be found in perldoc perlsub (Perl subroutines) linked from the perlvar:

    Any arguments passed in show up in the array @_ .

    Therefore, if you called a function with two arguments, those would be stored in $_[0] and $_[1].

    The array @_ is a local array, but its elements are aliases for the actual scalar parameters. In particular, if an element $_[0] is updated, the corresponding argument is updated (or an error occurs if it is not updatable).

    If an argument is an array or hash element which did not exist when the function was called, that element is created only when (and if) it is modified or a reference to it is taken. (Some earlier versions of Perl created the element whether or not the element was assigned to.) Assigning to the whole array @_ removes that aliasing, and does not update any arguments.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(8条)

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效