here documents

Discussion in 'Perl Misc' started by Rainer Weikusat, Apr 3, 2014.

  1. I'm currently forced to use/ write some non-entirely-trivial Javascript
    code for the first time in my life. This code is going to be mostly
    static with a few (one or two) parameters interpolated into it. And I
    need to use it in the context of more than one 'generated web
    page'. Because of this, I'm using a dedicated CGI script to write this
    code and presently, the relevant section looks like this (trivial early
    example because I'm not really familiar with the language and need to
    'find a way through it' first):

    print("Content-Type: text/javascript\n\n");
    printf(<<TT, $name);
    function showName()
    setTimeout(showName, 5000)

    setTimeout(showName, 5000)

    Something like this was posted as supposedly deterrent example here a
    while ago. In contrast to that, I think this is really an example of a
    here-document coming in extremely handy because I can just put the
    alien code into the Perl-script without it tripping up my editor and
    without using a strangely-formatted printf-statement.
    Rainer Weikusat, Apr 3, 2014
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.