For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2007 > heredoc issure









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author heredoc issure
Lnatz

2007-07-18, 6:59 pm

Hi, I'm having an issue with here docs, and I'm sure it's something
simple that I'm overlooking but it's annoying me. Here is a snippet
from my script.

sub usageAndDie {
print<<EOF;
[color=darkred]
runbook or both
[color=darkred]
EOF
exit 0;
}

Its failing with the error: Can't find string terminator "EOF"
anywhere before EOF at exec_rnbk.pl line 94.
Line 94 is "print<<EOF;".

Am I just missing something obvious here?

Thanks in advance!

Chas Owens

2007-07-18, 6:59 pm

On 7/18/07, lnatz <nmrabinovich@gmail.com> wrote:
> Hi, I'm having an issue with here docs, and I'm sure it's something
> simple that I'm overlooking but it's annoying me. Here is a snippet
> from my script.

snip
> Its failing with the error: Can't find string terminator "EOF"
> anywhere before EOF at exec_rnbk.pl line 94.
> Line 94 is "print<<EOF;".
>
> Am I just missing something obvious here?
>
> Thanks in advance!


Are you 100% certain there are no characters (even control characters)
before EOF?
Rob Dixon

2007-07-18, 6:59 pm

lnatz wrote:
>
> Hi, I'm having an issue with here docs, and I'm sure it's something
> simple that I'm overlooking but it's annoying me. Here is a snippet
> from my script.
>
> sub usageAndDie {
> print<<EOF;
>
> runbook or both
>
> EOF
> exit 0;
> }
>
> Its failing with the error: Can't find string terminator "EOF"
> anywhere before EOF at exec_rnbk.pl line 94.
> Line 94 is "print<<EOF;".
>
> Am I just missing something obvious here?


Have you got any whitespace before or after 'EOF' on the termination
line? A trailing space would prevent Perl from recognizing the
terminator but be invisible to you.

HTH,

Rob
John W. Krahn

2007-07-18, 6:59 pm

lnatz wrote:
> Hi, I'm having an issue with here docs, and I'm sure it's something
> simple that I'm overlooking but it's annoying me.


perldoc -q "HERE documents"


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
Christopher L Hood

2007-07-19, 6:59 pm

Rob Dixon

2007-07-19, 6:59 pm

christopher.l.hood@verizon.com wrote:
>
> lnatz wrote:
>
> I think that Rob was onto something, here is my 2 cents.
>
>
>
> The print line should be like this:
>
>
>
> print <<EOF
>
>
>
> and not
>
>
>
> print< < EOF
>
>
>
> like you have. I think maybe that what is happening is that the error
> that is being printed is saying that it cannot find “<space>EOF” before
> end of file. Put the space between the word print, and remove the
> spaces between the << and EOF, then ensure you don’t have a space or a
> tab or control characters before or after the EOF and it should work.
>
> Let me know if this helps.


Hi Christopher

(Please bottom-post your responses to this list so that long threads can
remain comprehensible. Thank you.)

It is important when posting software not to use HTML messages. As far as
I can tell, lnatz's original mail was in plain text, but your copy of her
message has lost indentation and gained spaces within the print statement
that weren't there. As you say, whitespace before the string terminator
will require the same whitespace at the end of the text, but whitespace
within the << operator as you describe won't be tolerated by the compiler
and would error. My thought was that there was whitespace after the string
terminator at the end of the string, which would be invisible in most
editors. Unfortunately the OP hasn't come back to say whether their
problem was solved.

Rob

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com