Sewi has asked for the wisdom of the Perl Monks concerning the following question:
Dear monks,
my @problems = (1,2,3); for my $problem (@problems) { push @problems, $problem if $problem; }
I expected this to work, because a for loop gets it's items before the first loop run but it turned out to be a infinitive loop because the newly pushed problems are also processed.
Thanks for your ideas,
Sewi
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: push in for loop
by ikegami (Patriarch) on Dec 12, 2011 at 16:31 UTC | |
|
Re: push in for loop
by jeffa (Bishop) on Dec 12, 2011 at 17:04 UTC | |
by NetWallah (Canon) on Dec 12, 2011 at 21:51 UTC | |
by Sewi (Friar) on Dec 12, 2011 at 17:28 UTC | |
by jeffa (Bishop) on Dec 12, 2011 at 17:32 UTC | |
|
Re: push in for loop
by jwkrahn (Abbot) on Dec 12, 2011 at 22:32 UTC | |
|
Re: push in for loop
by kejohm (Hermit) on Dec 12, 2011 at 22:28 UTC |