Re: multidimensional array assignment
- From: Kalle Olavi Niemitalo <kon@xxxxxx>
- Date: Wed, 15 Mar 2006 09:53:38 +0200
"ronak" <ronak.vlsi@xxxxxxxxx> writes:
@str=@temp;
This is a shallow copy. @temp is an array of references to
arrays. After the copy, @str will contain references to the same
arrays: @str and @temp are different arrays, but $str[$mm] refers
to the same array as $temp[$mm] does. So, when the next iteration
modifies $temp[$mm][$l], it is also modifying $str[$mm][$l].
I suppose the easiest way to construct new second-level arrays is:
@str = map [@$_], @temp;
If you want an even deeper copy, the Clone module might do the job.
.
- References:
- multidimensional array assignment
- From: ronak
- multidimensional array assignment
- Prev by Date: multidimensional array assignment
- Next by Date: Net::FTP connection status
- Previous by thread: multidimensional array assignment
- Next by thread: Re: multidimensional array assignment
- Index(es):
Relevant Pages
|
|