my @AoAoA = (
[
[ 'Flora & Fauna' => 'z0.html' ],
[ 'Pretty Flowers' => 'z1.html' ],
[ 'Deadly Vines' => 'z2.html' ],
],
[
[ 'Aquatic Creatures' => 'z3.html' ],
[ 'Pretty Fish' => 'z4.html' ],
[ 'Don\'t Eat' => 'z5.html' ],
],
);
That would let you keep the order without using Tie::IxHash. The AoAoA
can be printed using nested foreach loops:
print qq(<ul id="menu">\n);
for (@AoAoA) {
my ($label, $url) = @{ shift @$_ };
print qq( <li><a href="$url">$label</a>\n <ul>\n);
for my $pair (@$_) {
my ($label, $url) = @$pair;
print qq( <li><a href="$url">$label</a></li>\n);
}
print " </ul>\n </li>\n";
}
print "</ul>\n";
The above moduleless solution works nicely, as does the version posted in
the next thread.
Ultimately, I'm looking for a way to print each <li> also to include 1 of 3
css/html class variables, to be used for visual html formatting, eg.:
<li class=current_url>
<li class=this_group>
<li class=all_others>
To know which should be which, all I can go by is the current page name
being a variable imported into the perl script through
$ENV{"DOCUMENT_NAME"}. Note that the menu would be ssi/perl generated onto
otherwise static .html pages, which are the pages as linked in the arrays.
Through knowing the file name, it should be possible to know which array
group it is within, and for it, print a relevant <li class=$variable>.
For example, if a user is accessing z1.html, I would like to print <li>'s
for z0.html and z2.html, as <li class=current_group>, as z1.html is amongst
that group of links.
Whilst the <li> containing z1.html itself would print as <li
class=current_url>.
And all others, being z3.html, z4.html and z5.html, to print as <li
class=all_others>
Could the above AoAoA/loop format be extended for this, or would a different
array/loop method be needed considering this last mentioned functionality?
Thanks again,
Michael
--
Q: How does the Polish Constitution differ from the American?
A: Under the Polish Constitution citizens are guaranteed freedom of
speech, but under the United States constitution they are
guaranteed freedom after speech.
-- being told in Poland, 1987