using Print << marker with require statement?

M

me

A noob question about using a require statement. I tried including a
file that looks like this:

print << "endOfText";
Sample Text
endOfText

This works fine in the main program but if I put it in a separate file
and include it with a require statement, it fails with the message
"Can't find string terminator "endOfText" anywhere before EOF at
test-require.pl line 1.

There must be some Perl subtlety that I am missing.

Thanks,
 
S

sln

A noob question about using a require statement. I tried including a
file that looks like this:

print << "endOfText";
Sample Text
endOfText

This works fine in the main program but if I put it in a separate file
and include it with a require statement, it fails with the message
"Can't find string terminator "endOfText" anywhere before EOF at
test-require.pl line 1.

There must be some Perl subtlety that I am missing.

Thanks,

Try this, it might be looking for newline embedded markers:
"\nendOfText\n";

use strict;
use warnings;

print << "endOfText";
Sample Text
endOfText
endOfText

__END__

-sln
 
S

sln

A noob question about using a require statement. I tried including a
file that looks like this:

print << "endOfText";
Sample Text
endOfText

This works fine in the main program but if I put it in a separate file
and include it with a require statement, it fails with the message
"Can't find string terminator "endOfText" anywhere before EOF at
test-require.pl line 1.

There must be some Perl subtlety that I am missing.

Thanks,

Its looking for newline delimeted string.
In your body it is
\n' endOfText'\n
If you want to leave it that way then put
any body spaces after the first newline and
before the last newline.


print << " endOfText";
Sample Text
endOfText

-sln
 
M

me

Works for me, so there must be something you're not telling us. I
prseume your example above is indented for the benefit of Usenet, and
'endOfText' is actually at the start of the line? It needs to be.

Yes... all statements are actually left justified. Any other ideas?
The code works fine within a program, and other code I "require" also
works fine.
If you are trying to use this for templating, there are better
approaches. Search the group (or search.cpan.org) for 'template' to get
some suggestions.

Understood. At this point I'd just like to understand why this code
does not work.
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top