On Sat, Jul 25, 2009 at 5:03 AM, Moritz Lenz<mor...@faui2k3.org> wrote:
> Presumably you want here-docs, which can be indented in Perl 6:
>
>    perl 6 code
>    perl 6 code
>    $script.say(Q:to<END>);
>         output code
>         output code
>         END
>
> The leading whitespace will be pruned from the string.

All of the leading whitespace, or only up to the amount on the first
line?   That's always been the problem with here-docs.  Rakudo doesn't
seem to support Q:to yet, so I can't test, but if I do this:

say(Q:to<END>);
    line 1
        line 2
            line 3
    END

I would want line1 to be flush left, while line 2 is indented, and
line 3 indented more.

The solutions to do this in Perl5 are a bit hacky and fragile,
something like replacing the simple

print <<END;

with

(my $str = <<"    END") =~ s/^\s{4}//gms; print $str;

or similar, which is a lot of work just to get more-legibly-formatted
source code.

-- 
Mark J. Reed <markjr...@gmail.com>

Reply via email to