in reply to Re: Why do here-docs have to end with a newline, not EOF?
in thread Why do here-docs have to end with a newline, not EOF?
Really? I can reproduce the OP's results on WinXP and Linux.
WinXP, Perl 5.8.8, ActivePerl 820
>perl -e"print qq{print <<ENDHERE\nabc\nENDHERE}" > test.pl >perl test.pl Can't find string terminator "ENDHERE" anywhere before EOF at test.pl +line 1. >perl -e"print qq{print <<ENDHERE\nabc\nENDHERE\n}" > test.pl >perl test.pl abc >
Linux, Perl 5.8.4
$ perl -e'print qq{print <<ENDHERE\nabc\nENDHERE}' > test.pl $ perl test.pl Can't find string terminator "ENDHERE" anywhere before EOF at test.pl +line 1. $ perl -e'print qq{print <<ENDHERE\nabc\nENDHERE\n}' > test.pl $ perl test.pl abc $
If I were to guess, I'd say the parser looks for <"\nENDHERE\n"> instead of <"\nENDHERE" followed by either "\n" or end of file>, and it does so because it's easier and because every line is suppose to end with a line feed in unix.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Why do here-docs have to end with a newline, not EOF?
by turo (Friar) on May 12, 2008 at 01:18 UTC |
In Section
Seekers of Perl Wisdom