Hello Bob,

thanks a lot for your help!

read the documentation and you'll see that the basename() function can
remove extensions as well.
Done that :-)

The final app looks like this:

#!/usr/bin/perl
use strict;
use diagnostics;
use File::Basename;

fileparse_set_fstype( 'Unix' );

#HTML blah blah
print "Content-type: text/html\n\n";
print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 TRANSITIONAL//EN\">\n";
print "<html><head><title>My Links</title></head><body>\n";


print "<h1>My Links</h1>\n";

#reading filenames
my @filenames = glob "./data/*";
#sort filenames, I wonder if this is neccessary at all
@filenames = sort @filenames;

#create the links
my $name;
foreach my $filename (@filenames) {
open(FILE, $filename) or die "cannot open $filename!\n";
$name = fileparse($filename,'\..*');
print "<h2>$name</h2>\n<p>";
while (<FILE>) {
#read every line and format it properly
chomp;
my @hyperlink = split /\t/;
print "<strong><a href=\"$hyperlink[2]\">$hyperlink[0]</a></strong> - ";
print "$hyperlink[1]<br />\n";
}
print "</p>\n";
close FILE ;
}


print "</body></html>";

Next thing on my todo list is to be able to sort the links inside the data files alphabetically, either in the static txt files or in the resulting cgi file on my webserver, but that's something for a new day, I feel this will be a little more complicated. But then again, eventually I will come back and ask if I'm stuck :-)

Thanks a lot for all people who cared to read my postings and helped me one way or the other.

Stephan - soon-to-be-Perl-Guru


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to