bazz
08-06-2005, 09:05 PM
Hi,
I have resolved the intial issue but have left it here for the serach engine.
I have a new small issue which I shall post separately.
I am trying to build a flyout menu, which will show the following labels:
County->businessSubType->businessCategory->businessName.
The html and perl are shown below. I have it OK for the level - County but, Guesthouses and the others print out as many times as they are in the arrays.
Can any of you please help me make a mulitiple use of a var ouput only once - EG Guesthouses? I tried but it interefered with Down so that it outputted tons of times.
here's the perl
@listOfDirs = map{join'_', (split/_/)[1,2,4,5,0,3]} sort map{join'_', (split/_/)[4,0,1,5,2,3]} @listOfDirs;
foreach ( @listOfDirs ) {
chomp;
my ($businessName, $businessType, $businessSubType, $businessCat, $businesslocalRegion, $county, $grid) = split /_/;
$dirs{$county}{$businessCat}{$businessSubType}{$businessName}{$businessLocalRegion}{$businessType}{$ grid} = $_;
}
foreach my $county (sort keys %dirs) {
foreach my $businessCat (sort keys %{ $dirs{$county} }) {
foreach my $businessSubType (sort keys %{ $dirs{$county}{$businessCat} }) {
foreach my $businessName (sort keys %{ $dirs{$county}{$businessCat}{$businessSubType} }) {
if ( $county ne $countyGroup ) {
if ( $countyGroup ne '' ) { # ugly hack (better with hash arrays)
}
$countyGroup = $county;
print <<EOF;
<li><a href="#">$county</a><ul>
EOF
} # end of if countyGroup;
print qq(
<li><a href="#">$businessSubType</a>
<li><a href="#">$businessName</a></li>
);
} # end of foreach businessName
} # end of foreach businessSubType
} # end of foreach businessCat
} # end of foreach county
and here's the html outputted
<div id="control_panel_index_pages">
<ul id="nav">
<li><a href="#">Warwickshire</a><ul>
<li><a href="#">Guesthouse</a>
<li><a href="#">business Name</a></li>
<li><a href="#">Guesthouse</a>
<li><a href="#">another business name</a></li>
<li><a href="#">BnB</a>
<li><a href="#">another business name</a></li>
</li></ul>
</div></body></html>
Any advice appreciated
Bazz
I have resolved the intial issue but have left it here for the serach engine.
I have a new small issue which I shall post separately.
I am trying to build a flyout menu, which will show the following labels:
County->businessSubType->businessCategory->businessName.
The html and perl are shown below. I have it OK for the level - County but, Guesthouses and the others print out as many times as they are in the arrays.
Can any of you please help me make a mulitiple use of a var ouput only once - EG Guesthouses? I tried but it interefered with Down so that it outputted tons of times.
here's the perl
@listOfDirs = map{join'_', (split/_/)[1,2,4,5,0,3]} sort map{join'_', (split/_/)[4,0,1,5,2,3]} @listOfDirs;
foreach ( @listOfDirs ) {
chomp;
my ($businessName, $businessType, $businessSubType, $businessCat, $businesslocalRegion, $county, $grid) = split /_/;
$dirs{$county}{$businessCat}{$businessSubType}{$businessName}{$businessLocalRegion}{$businessType}{$ grid} = $_;
}
foreach my $county (sort keys %dirs) {
foreach my $businessCat (sort keys %{ $dirs{$county} }) {
foreach my $businessSubType (sort keys %{ $dirs{$county}{$businessCat} }) {
foreach my $businessName (sort keys %{ $dirs{$county}{$businessCat}{$businessSubType} }) {
if ( $county ne $countyGroup ) {
if ( $countyGroup ne '' ) { # ugly hack (better with hash arrays)
}
$countyGroup = $county;
print <<EOF;
<li><a href="#">$county</a><ul>
EOF
} # end of if countyGroup;
print qq(
<li><a href="#">$businessSubType</a>
<li><a href="#">$businessName</a></li>
);
} # end of foreach businessName
} # end of foreach businessSubType
} # end of foreach businessCat
} # end of foreach county
and here's the html outputted
<div id="control_panel_index_pages">
<ul id="nav">
<li><a href="#">Warwickshire</a><ul>
<li><a href="#">Guesthouse</a>
<li><a href="#">business Name</a></li>
<li><a href="#">Guesthouse</a>
<li><a href="#">another business name</a></li>
<li><a href="#">BnB</a>
<li><a href="#">another business name</a></li>
</li></ul>
</div></body></html>
Any advice appreciated
Bazz