in reply to Really need help with loop variable
Sorry to do this to you but...
<Lecture>
#or should it be 0..$total_elements?? for my $x (1..$total_elements+1) { }
So now lets look at your code:
Hmm.. first thing I see (beyond the above serious issues :-)is that your code is messy and confusing, so Ill clean it up a bit.. But I cant. Because there is no trailing " to finish your quoted section. So Ill make some dangerous assumptions about your code and show you what this could would look like (if I used symbolic refs that is)for ($x=1; $x <= $total_elements +1; $x++) {$varname = "fname_menu$x";$NEW_BUS_TXT = ${"NEW_BUS_TXT$x"}; $$varname = " <table border='1' width='100%' bgcolor='#BBEEEE'> <tr> <td width='100%'> <B>($x.)Using the pull down menu Select a member</B> ${NEW_PD$x} }
This stuff is scary... Sorry, but it's true.for my $x (1..$total_elements+1) { $varname = "fname_menu$x"; $NEW_BUS_TXT = ${"NEW_BUS_TXT$x"}; $$varname = <<"EOF_HTML"; <table border='1' width='100%' bgcolor='#BBEEEE'> <tr> <td width='100%'> <B>($x.)Using the pull down menu Select a member</B> ${NEW_PD$x} EOF_HTML }
What I think you are doing is trying to do is build a numbered set of tables, but the problem is where is the end of the table/row/cell? Is it in the mysterious symbolic reference ${NEW_PD$x}? And what is this for:$NEW_BUS_TXT = ${"NEW_BUS_TXT$x"};
So to be honest there isnt a lot that I (or IMO anyone else here) can do with this code.
OTOH: I can give you some more tips.
and the correspondingmy @fname_menu; foreach $x (0..$last_elem) { $fname_menu[$x]="Some Value maybe even HTML"; }
Be much easier and saner to deal with?print $fname_menu[$_] foreach 0..$#fname_menu;
my %hash; $hash{demerphq}="JAPH"; $hash{cal}="JAPL"; # learner.. :-) print $hash{cal}," ... ",$hash{demerphq};
Anyway, hope this is a bit of help at least. And please dont give up. Leave that use strict; right at the top of every script, exactly where it belongs. Fight and fight until all those nasty errors go away, in the end youll be happy you did (not to mention being a far better programmer).
Yves / DeMerphq
--
When to use Prototypes?
|
|---|