H
hudson
here's another function...I really like it, but I wonder if other people will.
basically, you have a hash of pages (scripts, whatever):
my %hash = (one => 'one.html',
two => 'two.html',
three => 'three.html'
);
and feed the calling page onto the script:
print menu('one', %hash);
sub menu {
my $source = shift;
my %scripts = @_;
my @temp;
for my $script (sort keys %scripts) {
if ($script eq $source) { push(@temp, "<b>$source</b>") }
else { push(@temp, "<a href=\"./$scripts{$script}\">$script</a>") }
}
my $output = "<center><small>\n";
$output .= join(" | \n", @temp);
$output .= "</center></small>\n<br>\n";
return $output;
}
of course, the sub is in a module far away from main ;-)
well, it is neat because it starts to take you away from static pages
and into database driven sites.
basically, you have a hash of pages (scripts, whatever):
my %hash = (one => 'one.html',
two => 'two.html',
three => 'three.html'
);
and feed the calling page onto the script:
print menu('one', %hash);
sub menu {
my $source = shift;
my %scripts = @_;
my @temp;
for my $script (sort keys %scripts) {
if ($script eq $source) { push(@temp, "<b>$source</b>") }
else { push(@temp, "<a href=\"./$scripts{$script}\">$script</a>") }
}
my $output = "<center><small>\n";
$output .= join(" | \n", @temp);
$output .= "</center></small>\n<br>\n";
return $output;
}
of course, the sub is in a module far away from main ;-)
well, it is neat because it starts to take you away from static pages
and into database driven sites.