Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

HERE document string terminator error

by perlpal (Scribe)
on Jul 10, 2009 at 07:32 UTC ( [id://778834]=perlquestion: print w/replies, xml ) Need Help??

perlpal has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I have used the Here document in part of my function to print multiple statements.When i execute the here document part only as a stand-alone script,it prints the expected output.However,when i use the here document within a function , I get the following error :

"Can't find string terminator "END" anywhere before EOF at generateTAFLib.pl line 110."

The codelet is

sub test(){ #variable declarations #some code print <<'END'; output END #some code }

I checked the perfaq and verified that the code conforms to the here document requirements.Can't figure out why i get this error.

The output spans a lot of lines and so have not mentioned it here.

Thanks in advance.

Replies are listed 'Best First'.
Re: HERE document string terminator error
by 1Nf3 (Pilgrim) on Jul 10, 2009 at 08:01 UTC

    I would guess that you have left a space after the END, or the whole sub is indented. The terminator must be all alone on a separate line for the whole thing to work. Check it.

    Regards,
    Luke

      I guess that was it!the space after the END. got it working now. Thanks!
Re: HERE document string terminator error
by moritz (Cardinal) on Jul 10, 2009 at 07:49 UTC
    The piece of code you posted here works fine for me.

    So please post something that really exhibits the error, otherwise we can't help you.

Re: HERE document string terminator error
by pKai (Priest) on Jul 10, 2009 at 08:27 UTC

    What moritz said.

    Nonetheless you might check for trailing whitespace behind the END terminator, which is an easy way to trigger your error.

    Update: Oops, heavy delay on cross post with 1Nf3.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://778834]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-18 23:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found