Are Perl subroutines call-by-reference or call-by-value?

后端 未结 5 1923
太阳男子
太阳男子 2020-12-08 00:59

I\'m trying to figure out Perl subroutines and how they work. From perlsub I understand that subroutines are call-by-reference and that an assignment (like my(@copy) =

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 01:33

    Firstly, you are confusing the @ sigil as indicating an array. This is actually a list. When you call Change(@a) you are passing the list to the function, not an array object.

    The case with the hash is slightly different. Perl evaluates your call into a list and passes the values as a list instead.

提交回复
热议问题