ForeverLearning has asked for the wisdom of the Perl Monks concerning the following question:
Having a bit of a "dumb" moment here, can't figure out why this isn't working !
The result I get is :
4194304
8388608
The expected result is :
0
4194304
8388608
Here is my test case code:
#!/usr/bin/perl use 5.014; use strict; use warnings; use autodie; my @arrX = (0,4194304,8388608); my $count = 0; my $max = 3; sub sendX { return if $count >= $max; my $data = shift @arrX; return if not $data; $count++; say $data; } for (1 .. $max) { sendX; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: "shift" not working as expected
by LanX (Saint) on Mar 20, 2016 at 15:45 UTC | |
by ForeverLearning (Novice) on Mar 20, 2016 at 16:13 UTC | |
by ForeverLearning (Novice) on Mar 20, 2016 at 16:21 UTC | |
by LanX (Saint) on Mar 21, 2016 at 11:35 UTC | |
|
Re: "shift" not working as expected
by Anonymous Monk on Mar 20, 2016 at 15:47 UTC | |
|
Re: "shift" not working as expected
by flexvault (Monsignor) on Mar 20, 2016 at 16:40 UTC | |
by Marshall (Canon) on Mar 20, 2016 at 18:46 UTC |