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条)

报告相同问题?

悬赏问题

  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求
  • ¥20 antv g6 折线边如何变为钝角
  • ¥30 如何在Matlab或Python中 设置饼图的高度
  • ¥15 nginx中的CORS策略应该如何配置
  • ¥30 信号与系统实验:采样定理分析
  • ¥100 我想找人帮我写Python 的股票分析代码,有意请加mathtao