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

Re: Indented here docs?

Thread Previous | Thread Next
July 1, 2016 10:51
Re: Indented here docs?
Message ID:
Matthew Horsfall (alh) writes:

>   The following:
>     if (1) {
>       print <<~EOF;
>      Hello There
>       EOF
>   warns and prints:
>     Indentation on line 1 of heredoc doesn't match delimiter at
> /home/mhorsfall/ line 6.
>      Hello there

Ed Avis writes:

> 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.

Presumably you could achieve that by making the warning shown above be

Is there a reason to make this fatal for all users, rather than being a
warning that users can choose to be fatal or not?

Bikeshedding the wording of the warning/error message: Ed's specific
mention of ‘less than’ seems a good idea, rather than simply ‘doesn't
match’. I'm presuming that additional indentation on content lines isn't
a problem, and indeed will be retained (to maintain relative


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