my $a = q:t /END/
test
END;
$a.perl.say;
Above example works ok in pugs, But the problem is.
From S02
Heredocs are no longer written with <<, but with an adverb on any
other quote construct:
print qq:to/END/;
Give $amount to the man behind curtain number $curtain.
END
Which is correct?
Both of them are. See the table further down that says:
Short Long Meaning
===== ==== =======
...
:t :to Interpret result as heredoc terminator
...
Larry
> : print qq:to/END/;
> : Give $amount to the man behind curtain number $curtain.
> : END
> : Which is correct?
> Both of them are. See the table further down that says:
What about the semicolon? After the terminator, or after the opening
line?
--
"Your inertially corrupt space-time disagrees with me." -- Will McCarthy
http://surreal.istic.org/ It sounded right in my head.
Ah, missed that, thanks. On the opening line is correct, just as in
Perl 5. The heredoc is just a term with some indirection, and the
indirection is completely line oriented. The terminator must still
be on a line by itself, with nothing but whitespace. We could just
as easily have a POD indirection that said
print qq:from/FOO/;
and it would go looking for the nearest =begin FOO block to insert.
So syntactically, it's only sort of happenstance that with heredocs
the document happens to be "here". The inline-ness of it is secondary
to the line-orientedness of it, in my mind. And it is often not,
in fact, truly inline, as demonstrated by
print qq:to/FOO/, qq:to/BAR/;
...
FOO
...
BAR
It's really just a way to abstract a large string containing newlines
into a single token that doesn't.
Larry
On a somewhat related, somewhat unrelated note, I am a little bit
worried about the false duality of :to and :from.
Luke
Well, that's kinda why theres's no :from actually. It was probably
not beneficial to bring in a counterfactual example. Pod docs would
actually come in through %=POD<FOO> or some such. Heredocs are a
little more special because they have to interpolate from the local
lexical pad, so in that sense they really are a bit more in-line-ish.
Larry
If I remember correctly, Larry and Audrey discussed this at the
Chicago hackathon and updated the Synopsis at that time.
So my guess is that the Synopsis is correct.
-kolibrie