LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-15-2004, 06:39 PM   #1
Scruff
Member
 
Registered: Oct 2002
Location: Stoughton, MA
Distribution: Gentoo x86_64 & PPC
Posts: 949

Rep: Reputation: 30
Perl: here-document help


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
 
Old 01-15-2004, 08:40 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Try this one ...

Code:
#!/usr/bin/perl -w
print<<"EOF";
blah blah blah. this is a here-document
EOF


Cheers,
Tink
 
Old 01-15-2004, 08:49 PM   #3
Scruff
Member
 
Registered: Oct 2002
Location: Stoughton, MA
Distribution: Gentoo x86_64 & PPC
Posts: 949

Original Poster
Rep: Reputation: 30
Same error Tink. Check it out:

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.

What could be the problem here?
 
Old 01-15-2004, 09:19 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
What's your version of perl, and what does
plx stand for?

[edit]
/me remembers running into a few problems with 5.8.1, is back on 5.6.1
[/edit]


Cheers,
Tink

Last edited by Tinkster; 01-15-2004 at 09:22 PM.
 
Old 01-15-2004, 09:30 PM   #5
Scruff
Member
 
Registered: Oct 2002
Location: Stoughton, MA
Distribution: Gentoo x86_64 & PPC
Posts: 949

Original Poster
Rep: Reputation: 30
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!

Thanks Tink.
 
Old 01-15-2004, 09:48 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Ummm ... that code snippet is all you're
running there?
Try to add a empty new line after
the final EOF :} but no spaces around it

If this solves your problem google is your
friend, once again, because that's where
I got it from just then :)

Cheers,
Tink

 
Old 01-15-2004, 09:56 PM   #7
Scruff
Member
 
Registered: Oct 2002
Location: Stoughton, MA
Distribution: Gentoo x86_64 & PPC
Posts: 949

Original Poster
Rep: Reputation: 30
Google Rules

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.

Thanks!

Last edited by Scruff; 01-15-2004 at 10:10 PM.
 
Old 01-15-2004, 10:30 PM   #8
Scruff
Member
 
Registered: Oct 2002
Location: Stoughton, MA
Distribution: Gentoo x86_64 & PPC
Posts: 949

Original Poster
Rep: Reputation: 30
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!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i create a document, then a directory and save the document in it. jtdodge Linux - Newbie 9 06-15-2005 11:03 AM
Convert openoffice document into ms document through cli? bruno buys Linux - Software 0 07-05-2004 09:59 AM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM
Perl script: how to substitute through entire document? mister_math Programming 2 03-07-2003 11:38 PM
chrooting apache v2 (php, ssl, perl support) ; perl configuration markus1982 Linux - Security 3 01-26-2003 06:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration