Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML::Template

Status
Not open for further replies.

audiopro

Programmer
Apr 1, 2004
3,165
GB
I have taken this back to basics to troubleshoot an odd problem. I may just be missing something here but I just can't fathom it.

This simple nested loop is displaying all the second loop vars in each section where I want them to be separate.
The code isn't complete here but the script and template should be simple enough to follow.

I need another pair of eyes on it, thanks for looking.


Code:
@ITEMS=('ONE','TWO','THREE');
my @S1=('ORANGE','APPLE','CHERRY','PINEAPPLE','GRAPE');
my @S2=('DOG','CAT','FROG','GOAT','SHEEP','CAMEL');
	foreach $line (@ITEMS){
		my %row_data;
		$row_data{ITEM} = shift(@S1);
		for($x=0; $x<2; ++$x){
			my %sub_data;
			$sub_data{SUB_ITEM} = shift(@S2);
			push(@sub_item_data, \%sub_data);
		}

		$row_data{SUB_LOOP} = \@sub_item_data;
		push(@item_data, \%row_data);
	}
	$PageMenu->param(ITEM_LOOP => \@item_data);
	print $PageMenu->output();




------- template ---------

<TMPL_LOOP NAME='ITEM_LOOP'>
	it - <TMPL_VAR NAME='ITEM'><br>
	<TMPL_LOOP NAME='SUB_LOOP'>
		sub - <TMPL_VAR NAME='SUB_ITEM'><br>
	</TMPL_LOOP>
</TMPL_LOOP>

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top