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

When I used the code shown below I got the following error:
Can't find string terminator "EOF" anywhere before EOF at /export/home +/egate/Per l_Development/monitor_log.pl line 49.
Not sure where I need to make a change I got this from the Perl cookbook.
open(SENDMAIL, "|/usr/lib/sendmail -oi -t -odq") or die "Can't fork for sendmail: $!\n"; print SENDMAIL <<"EOF"; From: User Originating Mail <me\@host> To: Final Destination <you\@otherhost> Subject: A relevant subject line Body of the message goes here, in as many lines as you like. EOF close(SENDMAIL) or warn "sendmail didn't close nicely"; Can't find string terminator "EOF" anywhere before EOF at /export/home +/egate/Per l_Development/monitor_log.pl line 49.

update (broquaint): added <code> tags
update 2 (broquaint): title change (was Perl Error)

Replies are listed 'Best First'.
(z) Re: Perl Error
by zigdon (Deacon) on Nov 27, 2002 at 17:48 UTC

    I'm guessing that the line that has the "EOF" in it has spaces before the EOF. Since you're telling perl that the heredoc will terminate with a line that matches /^EOF$/, and you don't have that line, perl complains.

    Also, read on how to use <CODE> tags, to make your post more readable

    -- Dan

Re: Perl Error
by tachyon (Chancellor) on Nov 27, 2002 at 18:08 UTC

    Your problem will be that the heredoc closing token 'EOF' need to be on a line by itself with no leading or trailing space. ie

    print SENDMAIL <<"EOF"; [blah] EOF

    You can also use the qq operator like this:

    print SENDMAIL qq! [blech] !; close(SENDMAIL) or warn "sendmail didn't close nicely";

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      Thank you tachyon. This solve my problem. Thank you very much