Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax error near print

Status
Not open for further replies.

ITadvice

IS-IT--Management
Jul 22, 2008
38
US
I have the following lines in my code:

Code:
my $last_time = 0;
print $q->header("text/html\n\n"), #This is line 92
      $q->start_html(-title=>"Data Report"),
      "This is the report for~~<br>";

When I run the program, I keep getting "syntax error near 'print' line 92". I have used the same format in other codes but this is the only one that gives this error. How can I solve this? I changed $q so that it is now my $q = CGI->new; Is there something wrong with my format?

 
Code:
#!perl

[red]use CGI;
use strict;[/red]

my $last_time = 0;
[red]my $q = new CGI;[/red]

print $q->header("text/html\n\n"), #This is line 92
$q->start_html(-title=>"Data Report"),
"This is the report for~~<br>";
This works for me with a few lines added

Keith
 
Thanks Keith but I already had that in my code. I guess I should have mentioned that before.
 
$q = CGI->new; (this is OK)

There is no syntax error in the code you posted but try removing the \n\n part of the header as the CGI module takes care of that for you.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Code:
[kirsle@fonalityxp ~]$ perl -c
my $last_time = 0;
print $q->header("text/html\n\n"), #This is line 92
      $q->start_html(-title=>"Data Report"),
      "This is the report for~~<br>";
__END__
- syntax OK

The code there is fine without using strict.

The syntax error may end up being up or down a couple of lines in the code (i.e. mismatched brackets or non-ending quotes or block of some sort), which is why it said "near" print.

-------------
Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top