#use wml::std::case global=lower # Usage: # 0. Edit the "index file" with file list. # 1. include this file with "current page" and "index file" # #include "guide.wh" page="about.html" index="Index" # 2. use tag to display. <: { my $page = '$(page)'; my $index = '$(index)'; my $prev, $next, $target; my @filelist; $prev = $next = ""; $target = 0; # File Read open(INDEX, $index); foreach () { chop; next if /^#/; next if /^$/; push @filelist, $_; } close(INDEX); # Target File Search foreach (@filelist) { last if ($_ eq $page); $target++; } # File Setting $prev = $filelist[$target-1] if $target > 0; $next = $filelist[$target+1]; $prev = "" if $prev eq $filelist[0]; # Guide Printout if ($prev ne "") { print qq!PREV!; } else { print qq!PREV!; } print ' << '; print "TOP"; print ' >> '; if ($next ne "") { print qq!NEXT!; } else { print qq!NEXT!; } } :>