CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
strange warning

 



digioleg54
User

Sep 6, 2016, 8:53 AM

Post #1 of 14 (5525 views)
strange warning Can't Post

I have two scripts:

$num = 5;
$a = <<'_END_';
This is the first line
The number is $num
This is the last line
_END_
print "[$a]\n";

######################
$num = 5;
$a = <<"_END_";
This is the first line
The number is $num
This is the last line
_END_
print "[$a]\n";

I didn't put #!/usr/bin/per
use warnings;
use stricts; here, but did it in my scripts

Both of them give the same warning:

Can't find string terminator "_END_" anywhere before EOF at warning.pl line 6.

Do you know why?


FishMonger
Veteran / Moderator

Sep 6, 2016, 9:07 AM

Post #2 of 14 (5523 views)
Re: [digioleg54] strange warning [In reply to] Can't Post

You need to have at least one blank line after the terminating "_END_".


(This post was edited by FishMonger on Sep 6, 2016, 9:07 AM)


digioleg54
User

Sep 6, 2016, 9:35 AM

Post #3 of 14 (5520 views)
Re: [FishMonger] strange warning [In reply to] Can't Post


Code
#!/usr/bin/perl 
use warnings;
use strict;

my $num = 5;
my $a = <<'_END_';

This is the first line
The number is $num
This is the last line
_END_
print "[$a]\n";

################

Code
#!/usr/bin/perl 
use warnings;
use strict;

my $num = 5;
my $a = <<"_END_';

This is the first line
The number is $num
This is the last line
_END_
print "[$a]\n";


The same warning


(This post was edited by FishMonger on Sep 6, 2016, 9:38 AM)


FishMonger
Veteran / Moderator

Sep 6, 2016, 9:41 AM

Post #4 of 14 (5514 views)
Re: [digioleg54] strange warning [In reply to] Can't Post

You didn't add the blank line like I told you. You need a blank line just before the print statement.


Code
#!/usr/bin/perl  
use warnings;
use strict;

my $num = 5;
my $a = <<"_END_";

This is the first line
The number is $num
This is the last line
_END_

print "[$a]\n";



(This post was edited by FishMonger on Sep 6, 2016, 9:42 AM)


FishMonger
Veteran / Moderator

Sep 6, 2016, 9:43 AM

Post #5 of 14 (5512 views)
Re: [digioleg54] strange warning [In reply to] Can't Post

Please post these beginner level questions in the Beginner section, not the Intermediate section.


digioleg54
User

Sep 6, 2016, 9:48 AM

Post #6 of 14 (5509 views)
Re: [FishMonger] strange warning [In reply to] Can't Post

The same result


FishMonger
Veteran / Moderator

Sep 6, 2016, 9:53 AM

Post #7 of 14 (5506 views)
Re: [digioleg54] strange warning [In reply to] Can't Post

Then you're still doing something wrong but I can't say what because you haven't shown your updated code.


Code
c:\test>type test.pl 
#!/usr/bin/perl
use warnings;
use strict;

my $num = 5;
my $a = <<"_END_";

This is the first line
The number is $num
This is the last line
_END_

print "[$a]\n";


Code
c:\test>test.pl 
[
This is the first line
The number is 5
This is the last line
]



FishMonger
Veteran / Moderator

Sep 6, 2016, 9:57 AM

Post #8 of 14 (5504 views)
Re: [digioleg54] strange warning [In reply to] Can't Post

FAQ: Why don't my <<HERE documents work?
http://perldoc.perl.org/perlfaq4.html#Why-don%27t-my-%3c%3cHERE-documents-work%3f


digioleg54
User

Sep 6, 2016, 10:19 AM

Post #9 of 14 (5502 views)
Re: [FishMonger] strange warning [In reply to] Can't Post

I know it must be like that, but it is probably my iMac.

Thanks,
Oleg


FishMonger
Veteran / Moderator

Sep 6, 2016, 11:55 AM

Post #10 of 14 (5495 views)
Re: [digioleg54] strange warning [In reply to] Can't Post

Heredocs work the same on all OS's and on all perl versions.


digioleg54
User

Sep 6, 2016, 12:38 PM

Post #11 of 14 (5491 views)
Re: [FishMonger] strange warning [In reply to] Can't Post

I have terminal and bash, and perl version 22, subversion 2 , may be something was not loaded


FishMonger
Veteran / Moderator

Sep 6, 2016, 12:58 PM

Post #12 of 14 (5488 views)
Re: [digioleg54] strange warning [In reply to] Can't Post

That's very unlikely. You just have a syntax error.

Make sure you don't have any spaces before or after the closing token (i.e., _END_) and that you have a blank line after it.

If you're simply doing a copy/past of the sample I posted, then it won't work due to how this forum parses the submits i.e., it adds an extra space to the end of each line which you will need to remove.


digioleg54
User

Sep 6, 2016, 1:03 PM

Post #13 of 14 (5486 views)
Re: [FishMonger] strange warning [In reply to] Can't Post

I already check everything. There are no spaces before and after token


digioleg54
User

Sep 6, 2016, 1:09 PM

Post #14 of 14 (5484 views)
Re: [digioleg54] strange warning [In reply to] Can't Post

I made a separate program, which I types. Everything is working.

Thanks,
Oleg

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives