Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Perl here-document results in "Can't find string terminator "EOF" anywhere before EOF"

Tags:

heredoc

perl

I've been trying to use Here-documents, but it's not working. What might be wrong? Am I missing something obvious?

This is the entire contents of the file I'm trying to run (there are no spaces, or tabs anywhere):

print<<EOF;
text
EOF

I'm running it by saving it in Notepad or Notepad++ as a file called 3.pl.

Then by going into the DOS window under Windows 7 and typing perl 3.pl I get this message:

Can't find string terminator "EOF" anywhere before EOF at 3.pl line 1.

like image 952
Literat Avatar asked Feb 27 '11 23:02

Literat


1 Answers

Make sure your file has an empty line at the end. This should be four lines:

print<<EOF;
text
EOF 
#or a comment here works too ;)
like image 160
Konerak Avatar answered Oct 20 '22 05:10

Konerak