Hi all,
I am trying to write a script that will take the number of pages in a dir and create links on the bottom of the page for navigation, similar to what Tek-Tips has at the bottom of their pages.
I have a small script that I wrote that in my twisted logic, should work.
The ReadFolder sub is one I got from here (sorry but don't recall who posted it, but a big thanks to them
), so I am confident that it is working correctly
Here is the code that I haveso far....
And the error messages that I am getting from the server.....
<PRE>
malformed header from script. Bad header=
:
/cgi-bin/navlinks.cgi
unable to include "../cgi-bin/navlinks.cgi" in parsed fileprints1.shtml
</PRE>
So, am I completely off base here?
Any suggestions are greatly appreciated....
Jim
I am trying to write a script that will take the number of pages in a dir and create links on the bottom of the page for navigation, similar to what Tek-Tips has at the bottom of their pages.
I have a small script that I wrote that in my twisted logic, should work.
The ReadFolder sub is one I got from here (sorry but don't recall who posted it, but a big thanks to them

Here is the code that I haveso far....
Code:
#!/usr/bin/perl
$page = $input{'page'};
$folder = "../glocart";
&PrintHeader;
&ReadFolder;
&Show;
$I = $FirstPage;
print "<CENTER>\n";
print "<TABLE WIDTH=90%>\n";
print "<TR><TD ALIGN=CENTER>\n";
&WriteLinx;
print "</TD></TR>\n";
print "</TABLE>\n<CENTER>\n";
#############################
# Begin Subs
#############################
sub ReadFolder {
opendir (FOLDER, $folder) or die "No path available.";
@filenames= readdir(FOLDER);
closedir(FOLDER);
foreach my $file (@filenames) {
if ($file =~ /prints(\d+)_.*/i)
{
# catch the number
$num = $1;
# if new num is largest yet,
# replace maxNum with current num
# do this for all files and you will have
# largest number in the files.
if ($num > $maxNum) { $maxNum = $num; }
}
}
#------------------------------------------------------
1;
}
sub Show {
if ($maxNum <= 10) {
$FirstPage = 1;
$LastPage = $maxNum;
return 1;
}
if ($page <=5) {
$FirstPage = 1;
$LastPage = 10;
return 1;
}
if (($page + 5) < ($maxNum + 1)) {
$FirstPage = $page - 5;
$LastPage = $page + 5;
return 1;
}
if (($page + 5) > $maxNum) {
$FirstPage = $maxNum - 10;
$LastPage = $maxNum;
return 1;
}
}
sub WriteLinx {
if ($page > 1) {
print "<A HREF'\"prints($page-1).shtml\">";
print "Prev Page ";
print "</A>\n";
}
for ($I; $I < $LastPage; $I++) {
if ($I eq $page) {
print " $I \n";
next;
}
print "<A HREF=\"prints$I.shtml\">";
print " $I ";
print "</A>\n";
}
if ($page < $maxNum) {
print "<A HREF=\"prints($page + 1).shtml\">";
print " Next Page";
print "</A>\n";
}
}
sub PrintHeader {
return "Content-type: text/html\n\n";
}
And the error messages that I am getting from the server.....
<PRE>
malformed header from script. Bad header=
:
/cgi-bin/navlinks.cgi
unable to include "../cgi-bin/navlinks.cgi" in parsed fileprints1.shtml
</PRE>
So, am I completely off base here?
Any suggestions are greatly appreciated....
Jim