0

i have something like:

    #!/usr/bin/perl

use strict;
use warnings;
use CGI::Simple;
use DBI;

my $cgi = CGI::Simple->new;


if ($cgi->param('selid'))
{

    print $cgi->header, <<HTML;
    <br/>this is SELECT 
     HTML
}
elsif ($cgi->param('delid'))
{

    print $cgi->header, <<HTML; 
    <b>this is DELETE</b>
    HTML
}
elsif ($cgi->param('upid'))
{
    print $cgi->header, <<HTML; 
    <b>this is UPDATE</b>
    HTML
}

when i run this i get an error like:

Error message: Can't find string terminator " HTML" anywhere before EOF at C:/xampp/htdocs/perl/action.pl line 14. ,

and when give space between << and HTML;

like :print $cgi->header, << HTML;

error changes to:

Error message: Can't find string terminator " " anywhere before EOF at C:/xampp/htdocs/perl/action.pl line 14. ,

what would be the reason for this?

note: parameters are passed from another page('selid' or 'delid' or 'upid')

1
  • By the way, the shebang at the start of the script also has to be at the start of the line to work as intended. Commented Apr 5, 2010 at 9:34

1 Answer 1

3

It is necessary to make sure that the end tag for heredocs is at the beginning of the line or the tag will not be recognized by the interpreter. So put the HTML ending at the very beginning of the line, no whitespace before it.

Also keep in mind that using double quotes around the start tag (eg print <<"HTML";) allows variables to be interpolated, using single quotes doesn't and using the tag without either behaves like double quotes

Sign up to request clarification or add additional context in comments.

1 Comment

Also, it's recommended to use either kind of quote instead of no quotes, so that the behavior is explicit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.