fawad12 has asked for the wisdom of the Perl Monks concerning the following question:

I'm using BBC's software to convert html file into text version. when I run the file I got a error message and it is:

The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

"use" not allowed in expression at F:\extranet\htdocs\cgi\parser.pl line 18, at end of line syntax error at F:\extranet\htdocs\cgi\parser.pl line 18, near "use Socket" BEGIN not safe after errors--compilation aborted at F:\extranet\htdocs\cgi\parser.pl line 19.

My code is :

www.newman.ac.uk/cgi/ #!/usr/local/bin/perl -Tw # parser.pl v 1.5.12 # by Wayne Myers (et al) # Enormous thanks to: # Chay Palton, Damion Yates, George Auckland, # Dan Tagg, T.V. Raman, Mark Foster, Peter Burden, # Jack Evans, Steve at wels.net, Gene D., Maurice Walshe # Mark A. Rowe and many others. # parser.pl aka BETSIE is Copyright 1998 - 2001 BBC Digital Media # See LICENCE for full licence details # See README for more information # See ChangeLog for version changes # modules use Socket; use strict; # variables my $version = "1.5.12"; # version number my @x = (); # all the lines of the html page we're parsing my $contents = ""; # @x concatenated my $inpath = ""; # path_info string from which we get the rest my $qs; # query string, used for authorisation process my $root = ""; # domain of the page we are looking at my $path = ""; # path of the page we are looking at my $file = ""; # name of the file we are looking at my $postdata = ""; # POST method data my $method = "GET"; # $method remains this way unless we get POST +data my $length = -1; # but is the length of content if any greater +in a POST my $count; # counter for main request loop my $httptype; # http type of request my $code; # http return code my $msg; # http message my $newurl; # used to store redirect target my $tag; # used to store meta redirect tags my $loop_flag; # flag used to make sure we get the right page my $script_flag; # flag used to see if we are in script tags or + not my $ws_flag; # flag used to minimise unnecessary white space my $set = 0; # is 1 if we want the settings page my $body; # the body tag my $cookies; # cookies we want to pass on to other server my @setcookies; # cookies server wants us to pass onto user my $header; # the http header we want to send the browser my $extraheaders; # extra headers to send the server on requests my $nocontenttype = 1; # flag unset when content type is printed my $basic_realm; # contains strin my $set_auth = 0; # flag set when required authorisation is prov +ided # VARIABLES YOU MIGHT WANT TO CHANGE: my $pathtoparser = "http://$ENV{'www.newman.ac.uk/cgi/'}$ENV{'parser.p +l'}"; my $selfnuke = "(?:$pathtoparser|$ENV{'parser.pl'})"; # used to elimin +ate textonly links to self my $maxpost = 65536; # is maximum number of bytes in a POST my $parsehome = "http://www.bbc.co.uk/education/betsie/"; my $name = $ENV{'parser.pl'}; # name of this file $name =~ s/^.*\/(\w\.+)$/$1/; my $agent = $ENV{'HTTP_USER_AGENT'}; # pretend to be the calling br +owser my $allowchars = '[a-zA-Z0-9_.\-\/\#\?\&\=\%\~\+\:]'; # allowed charac +ters my $alarm = 20; # number of seconds before we time out # variables for colour/font settings etc # be sure to amend make_body() if you amend them my $setstr = "/0005"; # is default string for settings. my $chsetstr = "/1005"; # string used for default change settings pag +e # next five arrays are for each set of colour options. feel free to ad +d to or amend these. my @bg = ('#000000', '#FFFFFF', '#0000FF', '#FFFFCC'); my @text = ('#FFFF00', '#000000', '#FFFFFF', '#000000'); my @link = ('#00FFFF', '#0000FF', '#FFFFCC', '#0000FF'); my @vlink = ('#00CCFF', '#0000CC', '#FFFF99', '#0000CC'); my @alink = ('#FFFF00', '#000000', '#FFFFFF', '#000000'); # ten fonts. again, you can change these if you like my @font_face = ("Verdana, Arial", "Times", "Courier", "Helvetica", "A +rial", "Bookman Old Style", "Geneva", "Chicago", "Courier New", "Sys +tem"); # VARIABLES YOU MUST SUPPLY: my $localhost = "www.newman.ac.uk"; # name of the actual machine which + is localhost # (not necessarily same as server na +me if its virtual) my $parsecontact = "wayne.myers\@bbc.co.uk"; my @safe = qw (www.newman.ac.uk);
Can anybody help me?
Fawad

Edit by castaway - added html and code tags

20040310 Edit by broquaint: Changed title from 'Please Help me?'

Replies are listed 'Best First'.
Re: Problems with BBC's CGI script?
by matija (Priest) on Mar 10, 2004 at 11:55 UTC
    First of all, you need to put <code> tags around your source, otherwise it looks like a right mess.

    Second of all, based on the linenumber in the error message and the linecount of the code you posted, it appears that the first line of your file is actualy

    www.newman.ac.uk/cgi/
    And that is no way for a propper CGI file to start.

    Also, that's the only reason I can see why the source you quoted could give you the error you quoted.

Re: Problems with BBC's CGI script?
by neniro (Priest) on Mar 10, 2004 at 11:48 UTC
    It's just a configuration file, isn't it?