in reply to Array elements in groups of 20
Other than the already suggested
@tapes_for_box1 = @unique_vault_list[0..19]; @tapes_for_box2 = @unique_vault_list[20..$#unique_vault_list];
you could use
@tapes_for_box1 = splice(@unique_vault_list, 0, 20); @tapes_for_box2 = @unique_vault_list;
which can be expanded into
my @tapes_by_box; push(@tapes_by_box, [ splice(@unique_vault_list, 0, 20) ]) while @unique_vault_list;
The difference is that splice removes the items from @unique_vault_list. (And it does so efficiently when removing from the start or end, as is the case here.)
|
|---|