Perl : Cant Find String Terminator

Discussion in 'Perl Misc' started by TP, Feb 11, 2004.

  1. TP

    TP Guest

    i get the message Cant Find String Terminator anywhere before EOF
    everytime i try to compile my script..

    i hope someone will help

    thanks

    here is the code

    #!/usr/bin/perl

    use CGI;
    my($query);
    $query = new CGI;


    ##Configuration section

    $dbpath = 'db.txt';

    $searchwhat = $query->param("searchwhat");
    $searchkey = $query->param ("searchkey");

    ##end of configuration

    #Begin search section

    open (DB, "<$dbpath") or die ("$!\n");

    while (<DB>){
    if ($searchwhat eq "all"){
    if (/$searchkey/i){
    push @matches, $_
    };
    }

    elsif ($searchwhat eq "mtype"){
    ($mtype, $mname, $mactor, $mactress, $mdes) = split (/\|/);
    if ($mtype =~ /$searchkey/i){
    push @matches, $_
    };
    }

    elsif ($searchwhat eq "mname"){
    ($mtype, $mname, $mactor, $mactress, $mdes) = split (/\|/);
    if ($mname =~ /$searchkey/i){
    push @matches, $_
    };
    }

    elsif ($searchwhat eq "mactor"){
    ($mtype, $mname, $mactor, $mactress, $mdes) = split (/\|/);
    if ($mactor =~ /$searchkey/i){
    push @matches, $_
    };
    }

    elsif ($searchwhat eq "mactress"){
    ($mtype, $mname, $mactor, $mactress, $mdes) = split (/\|/);
    if ($mactress =~ /$searchkey/i){
    push @matches, $_
    };
    }

    elsif ($searchwhat eq "mdes"){
    ($mtype, $mname, $mactor, $mactress, $mdes) = split (/\|/);
    if ($mdes =~ /$searchkey/i){
    push @matches, $_
    };
    }
    close(DB);

    #end of search section

    #start of response page

    $nummatches = @matches;



    print<<HTML_RESPOSE

    Content-type: text/html
    <HTML>
    <BODY>

    <h2>Your search for $searchkey return $nummatches matches.</h2>


    foreach $matchedEntry (@matches){
    print "$matchedEntry\n";
    }

    </BODY>
    </HTML>
    HTML_RESPONSE
    TP, Feb 11, 2004
    #1
    1. Advertising

  2. TP <> wrote:
    > i get the message Cant Find String Terminator anywhere before EOF
    > everytime i try to compile my script..


    [snip]

    > print<<HTML_RESPOSE
    > HTML_RESPONSE


    --
    Darren Dunham
    Senior Technical Consultant TAOS http://www.taos.com/
    Got some Dr Pepper? San Francisco, CA bay area
    < This line left intentionally blank to confuse you. >
    Darren Dunham, Feb 11, 2004
    #2
    1. Advertising

  3. Darren Dunham <> wrote in news:DjyWb.23897
    $:

    > TP <> wrote:
    >> i get the message Cant Find String Terminator anywhere before EOF
    >> everytime i try to compile my script..

    >
    > [snip]
    >
    >> print<<HTML_RESPOSE
    >> HTML_RESPONSE

    >


    Don't forget the terminating semi-colon:

    print <<HTML_RESPONSE;
    <html>
    <body>
    <ul>
    <li>I will learn to spell right</li>
    <li>I will learn to spell right</li>
    <li>I will learn to spell right</li>
    <li>I will learn to spell right</li>
    <li>I will learn to spell right</li>
    <li>I will learn to spell right</li>
    ....
    </ul>
    </body>
    </html>
    HTML_RESPONSE

    --
    A. Sinan Unur
    (reverse each component for email address)
    A. Sinan Unur, Feb 12, 2004
    #3
  4. Donald LaFramboise <> wrote:

    > print<<HTML_RESPOSE
    >
    > needs a semicolon at the end of the line,



    No it doesn't.



    [snip TOFU, a clear indicator of the quality of the followup...]

    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Feb 14, 2004
    #4
  5. TP <> wrote:
    > i get the message Cant Find String Terminator anywhere before EOF
    > everytime i try to compile my script..



    > print<<HTML_RESPOSE
    >
    > Content-type: text/html
    ><HTML>
    ><BODY>
    >
    ><h2>Your search for $searchkey return $nummatches matches.</h2>
    >
    >
    > foreach $matchedEntry (@matches){
    > print "$matchedEntry\n";
    > }
    >
    ></BODY>
    ></HTML>
    > HTML_RESPONSE



    Others have already pointed out the cause of your syntax error,
    but nobody has told you that you can't interpolate code (like that).

    A "here-doc" is a way of quoting a _string_, so that foreach() is
    NOT seen as code, it is data.

    If you want code in the middle of the string, you can have 3
    statements: string_part1 then code then string_part2.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Feb 14, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Hirschfield

    Help: asyncore/asynchat and terminator string

    David Hirschfield, Jan 16, 2007, in forum: Python
    Replies:
    0
    Views:
    311
    David Hirschfield
    Jan 16, 2007
  2. Nagaraj
    Replies:
    1
    Views:
    842
    Lionel B
    Mar 1, 2007
  3. TP
    Replies:
    1
    Views:
    137
    Bob Walton
    Feb 11, 2004
  4. Replies:
    3
    Views:
    162
    Joe Smith
    Jul 17, 2005
  5. Trudge

    Can't find string terminator ...

    Trudge, Oct 23, 2006, in forum: Perl Misc
    Replies:
    21
    Views:
    1,252
    Henry Law
    Oct 26, 2006
Loading...

Share This Page