chaoticset has asked for the wisdom of the Perl Monks concerning the following question:
It's not that I'm desperate, but I'm frustrated.
The problem is simple: Iterate across two lists, both in the format name:stock:shown (where name is a text name and stock and shown are both numerical). As you iterate, check for duplicates (and, upon finding them, increment the current entry so that it reflects current stock). If there's not a duplicate, add the whole name:stock:shown to the array as a new entry.
However, this being probably the first reasonably interesting program I've had to write in Perl, the problem's solution is nothing but simple for me.
What I have just attempted is nested foreach loops; the outer one iterates across the new inventory, and the inner iterates across current inventory. However, before that I tried it the other way around (outer foreach current inventory, inner foreach new inventory) and also tried it in while loops. The first two resulted in neverending programs, and the third didn't work. I cannot, apparently, visualize this thing in Perl-space.
I didn't want my first question to be this stupid, but it is. Thanks for your time, in advance.
chaoticset
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Ludicrously Stupid Foreach Loop Question
by pjf (Curate) on Oct 09, 2001 at 08:17 UTC | |
by cLive ;-) (Prior) on Oct 09, 2001 at 09:28 UTC | |
by pjf (Curate) on Oct 09, 2001 at 09:55 UTC | |
|
Re: Ludicrously Stupid Foreach Loop Question
by cLive ;-) (Prior) on Oct 09, 2001 at 08:06 UTC | |
|
Re: Ludicrously Stupid Foreach Loop Question
by Zaxo (Archbishop) on Oct 09, 2001 at 08:34 UTC | |
|
Re: Ludicrously Stupid Foreach Loop Question
by blakem (Monsignor) on Oct 09, 2001 at 08:11 UTC | |
|
Already been thoroughly answered, but . . .
by Fletch (Bishop) on Oct 09, 2001 at 18:34 UTC | |
|
Re: Ludicrously Stupid Foreach Loop Question
by chaoticset (Chaplain) on Oct 10, 2001 at 00:18 UTC |