ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Ok. I have been learning perl from a bit of an old book (5.6) but the current 5.8 info from the web shows the same thing for a basic here-document, so why doesn't this work?
#!/usr/bin/perl -w
print<<EOF;
blah blah blah. this is a here-document
EOF
I keep getting "Can't find string terminator "EOF" anywhere before EOF at ./eof.plx line 2.
"
scruff@dabasement:~/documents/perl-stuff$ eof.plx
Can't find string terminator "EOF" anywhere before EOF at ./eof.plx line 2.
scruff@dabasement:~/documents/perl-stuff$ cat eof.plx
#!/usr/bin/perl -w
print<<"EOF";
blah blah blah. this is a here-document
EOF
I actually saw a few different examples for syntax of here-document while searching Google and tried them all to no avail.
v 5.8.2
I am not entirely sure what .plx stands for. I think I remember reading at the beginning of the book that .plx was perl extention. It's simply how the examples are named in the book and all my other scripts execute fine with .plx.
Just for kicks I tried saving it simply as eof and executing it that way, but I still receive that damned error
This is back in chap 1 even. I have made it through chap 3 with variables, interpolation, operators etc and never have any errors unless I make a stupid typo. I had taken a break though and wanted to refresh my memory so I went back through the chaps. I had this same problem the first time around too, but dismissed it as something to do with 5.6 vs 5.8. This time I wanted to Google out the solution but nothing seems to work!
I never came across that (or didn't interpret it properly)...
That was all I was running. It seemed a simple enough concept that I just wanted to prove so I copied the example word for word (well, subtituting blah blah for some of it ) There's one known error in this book anyway.
I added
print'nothing more', "\n";
as the last line and it worked fine.
Duh. I do need rest now. All of a sudden I realized what you actually meant by new line. Simply
"\n";
also works fine.
I have been playing with different scripts for 7 hours tonight and think it's past my bedtime!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.