Can't find string terminator “str” anywhere before EOF

喜你入骨 提交于 2019-12-04 03:08:51

问题


Why I get this error?

use strict;
use warnings;

my $str = <<str; 
88087   23/11/2010 
35192   25/07/2010 
B3J 5X9 17/08/2011 
C8U 5L6 16/08/2011 
F4Q 3B4 17/10/2010 
D3X 9P4 11/05/2010 
O7L 6Z8 28/02/2010 
W8L 9P2 05/09/2010 
str 

print $str;

my @arr = split/\n/,$str;
foreach (@arr) {
        my @tmp = split/\t/;
        print "$tmp[1]\n";
}

回答1:


You should not have a space here:

str 
   ^

The heredoc terminator should be on a line by itself and should not have anything (not even space) surrounding it.




回答2:


You can use diagnostics to get more verbose help on warning messages:

Can't find string terminator "str" anywhere before EOF (F) Perl strings can stretch over multiple lines. This message means that the closing delimiter was omitted. Because bracketed quotes count nesting levels, the following is missing its final parenthesis:

    print q(The character '(' starts a side comment.);

> If you're getting this error from a here-document, you may have included unseen whitespace before or after your closing tag. A good programmer's editor will have a way to help you find these characters.

 Uncaught exception from user code:

Can't find string terminator "str" anywhere before EOF




回答3:


Or Better Use Eclipse Perl Integration plug-in or Padre for editing your perl code. It shows real-time syntax related errors.



来源:https://stackoverflow.com/questions/4049855/cant-find-string-terminator-str-anywhere-before-eof

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!