Philipp Knechtle wrote:
Hi

Hello,

I am working with subarrays in a main array. When I copy the main array:

my @mainarray = ([1,2,3],[4,5,6],[7,8,9])
my @arraytwo = @mainarray

the references get copied. When I then modify the subarray data in
@arraytwo they are of course also modified in @mainarray.
So I use the command:

push @arraytwo, [EMAIL PROTECTED] for @mainarray

to copy the array. Is there a nicer way to do it?

For your simple AoA example:

my @arraytwo = map [EMAIL PROTECTED], @mainarray;



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to