develooper Front page | perl.perl5.porters | Postings from July 2016

Re: Indented here docs?

Thread Previous | Thread Next
H.Merijn Brand
July 1, 2016 11:03
Re: Indented here docs?
Message ID:
On Fri, 1 Jul 2016 10:38:28 +0000 (UTC), Ed Avis <>

> If this is added, there need to be checks that the indentation is consistent
> through the heredoc.  So for example this would not be allowed:
>     $foo = <<~END;
>     hello
>   there
>     END
> Error at line 3: leading indentation on line is less than the indentation of
> the end delimiter.
> At least, I would prefer that.  This restriction could be relaxed later if it
> turns out to get in the way, but it would be hard to add it if it weren't
> there originally, so I suggest it's safer to include the restriction in the
> first version of this new feature.

And what about - oh horror - mixed tabs and spaces?
Should it auto-expand leading whitespace?

<TAB><SPACE> is just three characters, <SPACE>{9} is nine characters.
Would you see the difference in

    my $foo = <<~"EOM";
	 First line
         Second line
    my $bar = $foo;

Looks (visually) correct, right? But it is three different leading space

H.Merijn Brand   Perl Monger
using perl5.00307 .. 5.23   porting perl5 on HP-UX, AIX, and openSUSE

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About