Taking References An array is a defined area of storage for list values, so we can generate a reference to it with the backslash operator: $arrayref = \@array; This produces a reference through which the original array can be accessed and manipulated. Alternatively, we can make a copy of an array and assign that to a reference by using the array reference constructor (also known as the anonymous array constructor) [...]: $copyofarray = [@array]; Both methods give us a reference to an anonymous array that we can assign to, delete from, and modify. The distinction between the two is important, because one will produce a reference that points to the original array, and so can be used to pass it to subroutines for manipulations on the original data, whereas the other will create a copy that can be modified separately.
发布评论
评论(8)
不是 是把row的内容复制一遍 然后再把新地址push到d里面
push @d, \@row 这个才是
回复 1# hbhswxy
push @row的引用 into @d as the last member of array.
复制代码[@list]和\@list是不同的,[@list]是新构造了一个数组引用,和原来的数组在内存中是不同地址。而\@list是直接取引用,该引用指向数组@list,所以是同一块内存地址。
是不是说更改[@list]中的内容不会影响@list中的内容; 而更改\@list中的内容则会更改@list中的内容。
谢谢哦。
本帖最后由 Perl_Er 于 2011-04-14 13:55 编辑
复制代码
回复 4# wxlfh
对,利用@row 和[ ]gu构造匿名arry的引用
@d 里放的是row的引用
匿名引用的 用法了。学习了。