http://qs1969.pair.com?node_id=73984

I made small sub to generate the part of the HTML, a navigation bar to be exact, for a project I'm working on and I would like people to comment on it so I can learn from my mistakes and pick a few good pointer along the way.

Thanks!


This sub works by having a hash and an array passed to it. The hash is in a format Name => 'Link' were the Name is the part that shown in the html and the link this the URL that the name set to. If a link is set to '' it will not be displayed as a link. The array is to set the order of the hash is displayed in. The Array can be omitted in which case the Hash will be displayed in random order.

Here is the code,
sub NavB { my %Links = %{+shift}; my @LinkOrder = @{+shift}; my ($Trn, $TL); if (@LinkOrder) { for ( $TL=0; $TL <= $#LinkOrder; $TL++ ) { if ($Trn) { $Trn .= " -> "; } if ($Links{$LinkOrder[$TL]}) { $Trn .= "<a href=\"$Links{$LinkOrder[$TL]}\" target=\"_self\"> <font size=4 face=\"Arial, Helvetica, sans-serif\" color=6666cc>$Li +nkOrder[$TL]</font><\/a>"; } else { $Trn .= "$LinkOrder[$TL]"; } } } else { foreach $TL (sort(keys(%Links))) { if ($Trn) { $Trn .= " -> "; } if ($Links{$TL}) { $Trn .= "<a href=\"$Links{$TL}\" target=\"_self\"> <font size=4 face=\"Arial, Helvetica, sans-serif\" color=6666cc>$TL +</font><\/a>"; } else { $Trn .= $TL; } } } return "\n<font size=4 face=\"Arial, Helvetica, sans-serif\" color=666 +6cc>$Trn</font>\n"; }


------
The Price of Freedom is Eternal Vigilance