in reply to How can increase number sequence in a variable
Hi, welcome.
Please see
Also see:
When you pass arrays to a loop each element will be handled separately.
If you want the arrays to be handled as units, you must pass a reference to them instead:perl -Mstrict -wE 'my @x=1..2; my @y=3..4; say "$_" for (@x, @y);' 1 2 3 4
If you then want to access the elements of the individual arrays you will have to dereference them in the loop:perl -Mstrict -wE 'my @x=1..4; my @y=1..4; say "$_" for (\@x, \@y);' ARRAY(0xcd9588) ARRAY(0xcd9510)
perl -Mstrict -wE 'my @x=1..2; my @y=3..4; say "@{$_}" for (\@x, \@y); +' 1 2 3 4
Hope this helps!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How can increase number sequence in a variable
by karlgoethebier (Abbot) on Nov 17, 2017 at 18:09 UTC | |
by 1nickt (Canon) on Nov 17, 2017 at 21:30 UTC | |
by karlgoethebier (Abbot) on Nov 18, 2017 at 10:37 UTC |