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

Hello guys, Heres a quick question. I am trying to append some XML to an existing string. The XML has quotations within it.
$mystring .=<< START; <XML version ="" attribute2="" ...blah START;
However my code fails because of the following: Use of bare << to mean <<"" is deprecated Kindly help

Replies are listed 'Best First'.
Re: appending xml to string
by philcrow (Priest) on Nov 10, 2006 at 16:28 UTC
    You should put explicit quotes around the heredoc terminator:
    $mystring .= <<'START'; ... START
    If you need to interpolate in the heredoc, use double quotes.

    Phil

Re: appending xml to string
by davorg (Chancellor) on Nov 10, 2006 at 16:40 UTC

    That won't cause your code to fail. What you are seeing is just a deprecation warning. Everything still works. It's just warning you that at some point in the future a feature that you are using is likely to be removed.

    If you see a warning or an error that you don't understand then you can look it up in perldiag to get more details. In this case, it says:

    Use of bare << to mean <<"" is deprecated
    (D deprecated) You are now encouraged to use the explicitly quoted form if you wish to use an empty line as the terminator of the here-document.
    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      Which means
      <<"START" ok (interpolates) <<'START' ok (doesn't interpolate) <<START Same as <<"START" << "START" Same as <<"START" << 'START' Same as <<'START' << START bad
Re: appending xml to string
by graff (Chancellor) on Nov 11, 2006 at 14:39 UTC
    You also need to be careful about your use of the semi-colon:
    $mystring .= << "START"; # semi-colon needed here <XML version="" attribute2="" ...blah START # Don't put a semi-colon on that line (or a comment or anything else).
    The end of the here-doc must be a line that contains exactly and only the string that you gave at the start, excluding the quotes (if any) and the semi-colon.
      Thanks graff..that helped