develooper Front page | perl.beginners.cgi | Postings from September 2012

Re: cgi development environment

Thread Previous | Thread Next
From:
Mike Williams
Date:
September 19, 2012 20:45
Subject:
Re: cgi development environment
Message ID:
CAMi_MSv3XoO0GcvETH+p9LSAdD-XuDGV_1qN2NqqQ2Njh6g5uQ@mail.gmail.com
On Wed, Sep 19, 2012 at 10:48 PM, Chris Stinemetz
<chrisstinemetz@gmail.com>wrote:


>  am having issues with my first script and have hopes someone may be
> able to explain to me whey it isn't working correctly.
>
> The error is coming form line 11 and the error is:
>
> Premature end of script headers: test2.cgi
> Bareword "left" not allowed while "strict subs" in use at
>

The error message is a major clue.  Try quotes around "left"


> /usr/lib/cgi-bin/test2.cgi line 7.
> Execution of /usr/lib/cgi-bin/test2.cgi aborted due to compilation errors.
> Premature end of script headers: test2.cgi
>
>
>   1 #!/usr/bin/perl
>   2 use warnings;
>   3 use strict;
>   4 use CGI;
>   5
>   6 my $q = CGI->new;
>   7 print $q->header(-type=>'text/html'),
>   8       $q->start_html('hello world'), # start the HTML
>   9       $q->h1({-align=>right},'hello world'),         # level 1 header
>  10       $q->h1({-align=>left});
>  11       $q->h1('some','contents');
>  12       $q->end_html;                  # end the HTML
>
>
You have a couple other issues.  Since you have one print statement, spread
over multiple lines, the semi-colons on lines 10 and 11 are bugs.  They
should be commas.  The semi-colons terminate the statement resulting in
syntax errors.

Mike

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About