in reply to Re^4: Troubles with Unshift and Push
in thread Troubles with Unshift and Push
Reading this node Arrays: A Tutorial/Reference will help you better learning.
Here is the code I did some changes in your code try and let me know.
use strict; use warnings; use Data::Dumper; my @num_weights = (36,264,188); my @leftovers = (1,2,3,4); my @hold_generations; my $i = 0; for(my $p = 0; $p < 1;$p++) #Go through all leftovers { my $pick = $leftovers[$p]; unshift @num_weights, $pick; #add item print Dumper(\@num_weights); push @hold_generations, @num_weights; #store new array print Dumper(\@hold_generations); splice @num_weights, 1, 1; #undo adding item print Dumper(\@num_weights); }
Note:
I do not have features module so I just used print()
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Troubles with Unshift and Push
by nat47 (Sexton) on Mar 04, 2015 at 05:37 UTC |