colwellj has asked for the wisdom of the Perl Monks concerning the following question:

I have a hash of arrays. Each site in this case has a minimum amount of items and a list of items. If a site dosen't have enough items I want to move those items to a different site.
I have solved the issues of deciding when and which site and I can already use shift to move each item one at a time.

However, the number of items could be large and I'm looking for a quicker way.
I want to know if I can somehow append the reference to the array to the end of another array and then de-reference the original 'pointer'. This should in theory be very quick.
$VAR1 = 'insert'; $VAR2 = [ { 'weight' => '', 'barcode' => '', 'flag' => '' } ]; $VAR3 = 'stream'; $VAR4 = [ { 'site' => [ { 'tosite' => '', 'runamt' => '', 'comboid' => '', 'minamt' => '', 'items' => [], 'tostream' => '' } ], 'maxsheet' => '', 'minsheet' => '', 'colour' => '', 'maxweight' => '', 'state' => {}, 'duplex' => '' } ]; $VAR5 = 'paper'; $VAR6 = '';


thanks in advance
//Updated to use Data::Dumper for structure - origin and destination are in the same structure John

Replies are listed 'Best First'.
Re: fast 'copy' of array to array
by Anonymous Monk on Oct 29, 2009 at 05:48 UTC
    Word problems? Oh noes! :) Please use Data::Dumper; and print Dumper($smallRepresentativeExample); and cut/paste the output, so that we know what kind of data structure you have. Do the same for the destination data structure. Thank you
Re: fast 'copy' of array to array
by SuicideJunkie (Vicar) on Oct 29, 2009 at 15:11 UTC
      SJ, I am doing that but when we are talking about thousands or more items that's a slow method. I was hoping to find a very quick method. After all an array is really only a pointer to a list. John
Re: fast 'copy' of array to array
by frieduck (Hermit) on Oct 29, 2009 at 15:34 UTC