> Show me where this fails and I'll shut up about it.
Actually, to me this thread underscores how broken here docs are
themselves. We already have q//, qq//, and qx// which duplicate their
functions far more flexibly. Question: Do we really need here docs?
Before you scream "Bloody murder", please read on...
> The current stumper, which involves problems 1, 2 and 3 is this:
>
> if( $is_fitting && $is_just ) {
> die <<POEM;
> The old lie
> Dulce et decorum est
> Pro patria mori.
> POEM
> }
>
> I propose that this work out to
>
> " The old lie\n Dulce et decorum est\n Pro patria mori.\n"
Let's look at what happens if we ignore here docs and instead use qq//
instead:
if( $is_fitting && $is_just ) {
die qq/
The old lie
Dulce et decorum est
Pro patria mori.
/;
}
Solves problem #1, indented terminator, except that it adds two newlines
(more later). However, it leaves 2 and 3. Let's try adding in a regexp:
if( $is_fitting && $is_just ) {
(my $mesg = qq/
The old lie
Dulce et decorum est
Pro patria mori.
/) =~ s/\s{8}(.*?\n)/$1/g;
die $mesg;
}
But the dang =~ operator make that ugly and hard to read, and requires a
$mesg variable. So let's try RFC 164's approach to patterns then:
if( $is_fitting && $is_just ) {
die subst /\s{8}(.*?\n)/$1/g, qq/
The old lie
Dulce et decorum est
Pro patria mori.
/;
}
Seems to work for me (and yes I'm working on a prototype of RFC 164's
functions).
I think we're trying to jam alot of stuff into here docs that maybe
shouldn't be jammed in, especially since Perl already has the q//
alternatives that are much more flexible. Don't get me wrong, I like
here docs and all, but I wonder if it isn't time for them to go?
I think I'd actually much rather see a new qh// "quoted here doc"
operator that solves these problems than trying to jam them all into the
existing shell-like syntax, which is a leftover oddity, really.
-Nate