On Wed, May 30, 2001 at 12:12:14PM -0700, cathair wrote:
> Here's how I DID get output without using the pulldown <snip>:
>
> my $i;
> for ($i = 0; $i <= $#array_name; $i++){
> print "$array_name[$i]\n";
> }
Do you know about perl's foreach loop construct? It is tailor-made for the
common case of doing something once for each element of an array. You could
re-write the above as:
foreach my $elem (@array_name) {
print "$elem\n"
}
The output is equivalent.
> THAT worked just dandy.
> But when I attempt...<snip>:
>
> my $j;
> print "<form name="a_form">\n";
> print "<select name="pull_my_finger" size=1>\n";
>
> for($j = 0; $j <= $#array_name; $j++){
> print "<option>$array_name[$j]\n";
> }
>
> print "</select></form>\n";
>
> </snip>
>
> ...it fails at me.
The code above looks fine. Are you sure you aren't doing something wrong
earlier in the script that does not become noticeable until this point?
How does the code fail at you?[1]
> Is there a way around this besides embedding the script (and output)
> midpage?
Cannot answer the question because of insufficient data.
[1] When asking for help, it is essential to provide specific information
about what you were doing and what went wrong. Saying 'it fails at me' is
a classic un-useful bug report. Better would be to provide the exact
faulty program output, or the perl debugging messages, if the script died
in compilation. Don't feel bad: since you are a newbie, you don't know
this stuff, but please take note for future reference.
--
Henry House
OpenPGP key available from http://hajhouse.org/hajhouse.asc
PGP signature