Syntaxerror with HERE document

R

Ronald Fischer

Why does the following statement give syntax error "undefined method
`STDOUT'"?

STDOUT <<-END
line 1
line 2
END

After all, the following works:

s=3D<<-END
line 1
line 2
END
STDOUT << s
--=20
Ronald Fischer <[email protected]>
Phone: +49-89-452133-162
 
S

Sebastian Hungerecker

Ronald said:
Why does the following statement give syntax error "undefined method
`STDOUT'"?

STDOUT <<-END
line 1
line 2
END

Because that's equivalent to STDOUT "bla", not STDOUT << "bla".
The << in your code is part of the heredoc syntax. You want
STDOUT << <<-END
line 1
line 2
END

HTH,
Sebastian
 
K

Killy Draw

Ronald said:
Why does the following statement give syntax error "undefined method
`STDOUT'"?

STDOUT <<-END
line 1
line 2
END
this means:
tmp_str="line 1\nline 2\n";
STDOUT tmp_str;
After all, the following works:

s=<<-END
line 1
line 2
END
STDOUT << s

and this means:
tmp_str="line 1\nline 2\n";
STDOUT<<tmp_str;


STDOUT is a var(the std out)
"<<" is a *method* of STDOUT
 
R

Ronald Fischer

Ronald said:
=20
Because that's equivalent to STDOUT "bla", not STDOUT << "bla".
The << in your code is part of the heredoc syntax. You want
STDOUT << <<-END
line 1
line 2
END

Of course, that's it!!! I must have been blind! Thanks a lot.

Ronald
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top