print <<"EOF"; 
Author Message
 print <<"EOF";

Okay, I've looked at the man pages and the FAQ and this doesn't seem to
work for me.  Do I have an old version of perl, or is my syntax just plain
wrong?

#!/usr/misc/bin/perl
#

    print <<"EOF";
outputting some
stuff to the
screen
EOF

Now, I got that out of the man pages and according to it, I should get
the following output:

outputting some
stuff to the
screen

Gee, I hope this question isn't as stupid as it sounds...

Joe



Fri, 28 Nov 1997 03:00:00 GMT  
 print <<"EOF";

Quote:

>Okay, I've looked at the man pages and the FAQ and this doesn't seem to
>work for me.  Do I have an old version of perl, or is my syntax just plain
>wrong?
>#!/usr/misc/bin/perl
>#
>    print <<"EOF";
>outputting some
>stuff to the
>screen
>EOF

Try using single quotes and getting rid of the semicolon.  i.e.

print <<'EOF'
outputting some
stuff to the
screen
EOF

sage.



Sat, 29 Nov 1997 03:00:00 GMT  
 print <<"EOF";

Quote:


>>Okay, I've looked at the man pages and the FAQ and this doesn't seem to
>>work for me.  Do I have an old version of perl, or is my syntax just plain
>>wrong?

>>#!/usr/misc/bin/perl
>>#

>>    print <<"EOF";
>>outputting some
>>stuff to the
>>screen
>>EOF

>Try using single quotes and getting rid of the semicolon.  i.e.

>print <<'EOF'

the double quotes and semicolons work for me.. maybe its implementation
specific. you didnt state what version of perl, what platform or what the
actual results were.

barry



Mon, 01 Dec 1997 03:00:00 GMT  
 print <<"EOF";
: >>Okay, I've looked at the man pages and the FAQ and this doesn't seem to
: >>work for me.  Do I have an old version of perl, or is my syntax just plain
: >>wrong?
: >
: >>#!/usr/misc/bin/perl
: >>#
: >
: >>    print <<"EOF";
: >>outputting some
: >>stuff to the
: >>screen
: >>EOF
: >

I just use:

print <<EOF;
some
text
EOF

no quotes anywhere, and the terminating 'EOF' must be the only text on
that line. If you were printing to a file, it would be:

print MYFILE<<EOF;
some
text
EOF

Craig.



Tue, 02 Dec 1997 03:00:00 GMT  
 print <<"EOF";

: Okay, I've looked at the man pages and the FAQ and this doesn't seem to
: work for me.  Do I have an old version of perl, or is my syntax just plain
: wrong?
:
: #!/usr/misc/bin/perl
: #
:
:     print <<"EOF";
: outputting some
: stuff to the
: screen
: EOF

That oughta work just fine.  Perhaps your stdout got redirected outside
the script, or your script is being run by a shell instead of by perl.
Were there any error messages like "print: not found"?  If so, then
your #! line didn't work.

Larry



Fri, 05 Dec 1997 03:00:00 GMT  
 print <<"EOF";

: >Okay, I've looked at the man pages and the FAQ and this doesn't seem to
: >work for me.  Do I have an old version of perl, or is my syntax just plain
: >wrong?

: >#!/usr/misc/bin/perl
: >#

: >    print <<"EOF";
: >outputting some
: >stuff to the
: >screen
: >EOF

: Try using single quotes and getting rid of the semicolon.  i.e.

: print <<'EOF'
: outputting some
: stuff to the
: screen
: EOF

: sage.
Um, not such sage advice.  You need the semicolon, as it
terminates the statement.  You can get away without it if
it is the last statement in your program, but that is still
bad programming practice and, strictly speaking, an error.

And the double quoting is correct.  Check out page 73 of
the camel book: print <<EOF; is the same as print <<"EOF".
The effect of the single quotes is to stop variable
interpolation, just like in a string.

As far as the original problem, I have no idea -- it works
fine for me -- and I cut the code out of your news article
and pasted it directly into a file: and it worked.  What
exactly doesn't work on your system.  Perhaps you have
some white space after your EOF on the last line? If you
send me your error messages I may be able to help.

        David.

--
David R.D. Macfarlane    |voice: 212-| "Intel Inside"

                         |           |   truth in advertising laws.



Sat, 06 Dec 1997 03:00:00 GMT  
 print <<"EOF";

Quote:



>: Okay, I've looked at the man pages and the FAQ and this doesn't seem to
>: work for me.  Do I have an old version of perl, or is my syntax just plain
>: wrong?
>:
>: #!/usr/misc/bin/perl
>: #
>:
>:     print <<"EOF";
>: outputting some
>: stuff to the
>: screen
>: EOF
>That oughta work just fine.  Perhaps your stdout got redirected outside
>the script, or your script is being run by a shell instead of by perl.
>Were there any error messages like "print: not found"?  If so, then
>your #! line didn't work.
>Larry

I assume that you didn't follow your ending EOF with a space?

--
____________________________________________________________________________
Perth, Western Australia   |  Be especially careful when operating in
Please send any rain       |  production mode without backups - that is,  
you don't need.            |  when not at work.



Sun, 07 Dec 1997 03:00:00 GMT  
 print <<"EOF";

|>

|> >: Okay, I've looked at the man pages and the FAQ and this doesn't seem to
|> >: work for me.  Do I have an old version of perl, or is my syntax just plain
|> >: wrong?
|> >:
|> >: #!/usr/misc/bin/perl
|> >: #
|> >:
|> >:     print <<"EOF";
|> >: outputting some
|> >: stuff to the
|> >: screen
|> >: EOF
|>
|> >That oughta work just fine.  Perhaps your stdout got redirected outside
|> >the script, or your script is being run by a shell instead of by perl.
|> >Were there any error messages like "print: not found"?  If so, then
|> >your #! line didn't work.
|>
|> >Larry
|>
|> I assume that you didn't follow your ending EOF with a space?
|>
|> --
|> ____________________________________________________________________________
|> Perth, Western Australia   |  Be especially careful when operating in
|> Please send any rain       |  production mode without backups - that is,  
|> you don't need.            |  when not at work.

Urethra!  I have the answer!
I was using an older version of perl that did not parse this correctly
(Thanks to whoever steered me to the solution and all the other helpful
responses I got  8)

It worked when I did this:

        print ""<<EOF;
blah
EOF

or something like that.  Actually, a day or two after I got the
answer, the "powers that be" upgraded perl, so now the original
program works.  What timing!




Mon, 08 Dec 1997 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. print <<"ending_print_tag";

2. ^<<<<<<<<<<<~~ with \n

3. print $FH <<EOF is not possible ??

4. print <<EOF

5. print <<EOF

6. print<<EOF

7. Embedded code in: print <<EOF ?

8. help with print <<EOF;

9. Frustrating script error - print <<EOF;

10. <<ENFofFTP "here-documnet" question

11. Indent around perl "print <<EOF" constructs?

12. ^<<<<<<<<<<< ~~ format question

 

 
Powered by phpBB® Forum Software