Bongo has asked for the wisdom of the Perl Monks concerning the following question:
I have two arrays. The first contains a list of headings for a table. The second contains a list of names that would go under the headings from the first array. I have to print the first heading, print the first ten names, print the second heading, print the second set of ten names, and so on. Here is the code I have so far:
foreach $heading (@headings) { print $heading; for ($count == 0;$count < 10;$count++) { $name = shift(@names); print $name; } }
My problem is...it prints the first heading and first ten names fine...then it finishes printing all the headings with no names. Like it only goes through the 'for' loop once. Can someone explain what i'm doing wrong?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: using two arrays to make a table
by jeffa (Bishop) on Jun 18, 2002 at 17:00 UTC | |
|
Re: using two arrays to make a table
by thelenm (Vicar) on Jun 18, 2002 at 16:28 UTC | |
|
Re: using two arrays to make a table
by mfriedman (Monk) on Jun 18, 2002 at 17:33 UTC | |
by demerphq (Chancellor) on Jun 18, 2002 at 18:32 UTC | |
by Abigail-II (Bishop) on Jun 19, 2002 at 13:31 UTC | |
by demerphq (Chancellor) on Jun 19, 2002 at 13:58 UTC | |
by Bongo (Initiate) on Jun 19, 2002 at 02:51 UTC | |
|
Re: using two arrays to make a table
by Abigail-II (Bishop) on Jun 19, 2002 at 13:25 UTC | |
|
Re: using two arrays to make a table
by LanceDeeply (Chaplain) on Jun 18, 2002 at 19:06 UTC | |
by graff (Chancellor) on Jun 19, 2002 at 02:45 UTC |