The Code
Below is all the Perl code. If you want to use it, it's best to download it from the site. If you copy and paste from below you many find formatting issues. Get The Code!
#!/usr/bin/perl
##
## Navigation script, displays current location on site as a breadcrumb trail.
##
## Rules:
## Foldernames and filenames must be descriptive.
## Use "_" where spaces where you want spaces.
## Every folder must have an index file.
print "Content-type: text/plain\n\n";
##Variables
#Environmental variable for path script was called from.
my $location = $ENV{DOCUMENT_URI};
#This will be used as the URL for each link in the naviation.
my $url_nav;
#Will contain the full path (minus home), invluding xhtml.
my $full_nav;
#The description we show for each link.
my $desc_nav;
##Sort our data
#Remove the leading "/" on folders, need this so we dont get a blank elemement when we do the spilt.
$location =~ s/\///;
#Split location into array by "\". Each element will be level in menu.
@nav = split(/\//, $location);
##Creating the menu
#Loop through every element in the array.
foreach $desc_nav (@nav)
{
#Check to see if its an index file, if it is, dont display it. You can add any here e.g. index.php, home.htm etc.
if ($desc_nav eq "index.shtml") {
# Do nothing.
} else {
#Add one more menu level each time we loop. For the URL.
$url_nav = "$url_nav$desc_nav/";
#Replace "_" with " " on folders.
$desc_nav =~ s/_/ /gi;
#Make each word start with capital.
$desc_nav =~ s/\b(\w+)\b/ucfirst($1)/ge;
#Remove file extensions on filename, including ".".
$desc_nav =~ s/\..*//;
#Add one more menu level each time we loop. For xhtml.
$full_nav = "$full_nav >> <a href=\"/$url_nav\">$desc_nav</a>";
}
}
#Print the finsihed xhtml menu.
print "<a href=\"/\">Home</a>$full_nav";