Oops, I tested it with my .php files 'cuz I didn't have any .txt files in my cgi-bin. And I found another little problem. Here is the new code, try this:
Code:
#!/usr/bin/perl
opendir(DIR,".");
@files = sort(grep(/\.txt$/,readdir(DIR)));
closedir(DIR);
print "Content-type: text/html\n\n";
$all_data = "";
foreach $file (@files) {
open(FILE,"$file") || die("Could not find $file. $!");
@lines = <FILE>;
close(FILE);
foreach $line (@lines) {
$line =~ s/\</</g; # optional
$line =~ s/\n/\<br\>/g; # optional
$all_data .= "$line";
}
$all_data .= "<br>";
}
print $all_data;
Mzzl, Chris