By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,199 Members | 952 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,199 IT Pros & Developers. It's quick & easy.

premature end of headers, code and output looks fine

P: n/a
hello, could someone please check this out?

#usr/local/bin/perl
# Filelist.pl version 0.1
use strict;
use CGI qw(:all);
use CGI::Pretty;
#use CGI::Carp qw(fatalsToBrowser);
use Cwd;
my ($query, $showdrive, $currentdir, @filelist, $file);
$currentdir=getcwd;
unless ($showdrive) {
$currentdir=~s/^(\w\:)//; #remove drive letter and trailing colon
$currentdir=~s/([^\/\\]$)/$1\//; #put on trailing slash
}
$query=CGI->new();
opendir(DIR,".");
@filelist=readdir(DIR);

print header('text/plain');
print $query->start_html(title=>'/dave/ Index'
);
print h1("File contents of : ",$currentdir);

foreach $file (@filelist){
# print a({href=>$file,target=>'_self'},$file); print "<br>";
}
print $query->end_html;

###########################################

it prints the following output.

prints the following output:

Content-Type: text/plain; charset=ISO-8859-1

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
lang="en-US"><head><title>title</tit
e>
<link rev="made" href="mailto:%2Fdave%2F%20Index" />
</head><body><h1>
File contents of :
</h1>
<a href="." target="_self">.</a>
<br><a href=".." target="_self">..</a>
<br><a href="filelist.pl" target="_self">filelist.pl</a>
<br></body></html>

i'm getting the error "premature end of script headers"

where can i find the error documentation, and what's wrong with the header?

also, i've been trying the CWD module and on some systems it fails because
it demands root access. it gets denied and the program crashes. is there any
way for it to work without doing that? or is there another module that does
the same thing but won't need root access?

thanks,
chris berkelaar
Jul 19 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
cy***********@hotmail.com (nomadx) wrote in message news:<1c**************************@posting.google. com>...
hello, could someone please check this out?

#usr/local/bin/perl
# Filelist.pl version 0.1
use strict;


Am I confused? thought you needed something
in first line more like

#!/usr/local/bin/perl

Ray
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.