Can not print blocks to files with <<

W

WH

print << 'okok';
lalala

okok

works fine, but with I try to do the same thing to write to a file


print $OUTPUTFILE << 'okok';
lalala

okok

not working
 
T

Tintin

WH said:
print << 'okok';
lalala

okok

works fine, but with I try to do the same thing to write to a file


print $OUTPUTFILE << 'okok';
lalala

okok

not working

"Not working" is a poor description of the problem. It would have been
better if you gave the actual error message generated, ie:

Can't use an undefined value as a symbol reference at foo line 1.

Anyway, move the $ from the filehandle and assuming you opened the file
correctly, you'll be fine.
 
W

WH

"Not working" is a poor description of the problem. It would have been
better if you gave the actual error message generated, ie:

Can't use an undefined value as a symbol reference at foo line 1.

Anyway, move the $ from the filehandle and assuming you opened the file
correctly, you'll be fine.

$ has nothing to do with it, as my handle has $. but I fixed it. here is the
current code

print {$OUTPUT} << "header";

I have to {} the output handle. don't know why.
 
G

Gunnar Hjalmarsson

WH said:
print << 'okok';
lalala

okok

works fine, but with I try to do the same thing to write to a file


print $OUTPUTFILE << 'okok';
lalala

okok

not working

To not confuse the print() function you can do

print $OUTPUTFILE (<< 'okok');

or

print $OUTPUTFILE <<'okok'; # space after '<<' removed
 
E

Eric Amick

$ has nothing to do with it, as my handle has $. but I fixed it. here is the
current code

print {$OUTPUT} << "header";

I have to {} the output handle. don't know why.

More than likely because

$xyz << "abc"

looks like you're using the left shift operator. Putting curly brackets
around the filehandle makes your intent clear.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top