Just to expand a little on FunkyMonk's answer, using a list as a fourth et seq. argument to splice allows you to insert elements into an array. The following silly example, spliceing the heron and parrot out of @mammals and into @birds, gives you the general idea.
use strict; use warnings; my @mammals = qw{ cat dog heron parrot stoat zebra }; my @birds = qw{ coot sparrow }; print qq{Before:\n @mammals\n @birds\n}; splice @birds, 1, 0, splice @mammals, 2, 2; print qq{ After:\n @mammals\n @birds\n};
The output.
Before: cat dog heron parrot stoat zebra coot sparrow After: cat dog stoat zebra coot heron parrot sparrow
I hope this is of interest.
Cheers,
JohnGG
Update: AnomalousMonk pointed out that I really needed a "Before" and "After" rather than two "Before"s. That's what comes of careless cut 'n' paste development :-(
In reply to Re: Array index move into another array
by johngg
in thread Array index move into another array
by rose
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |