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

Re: Indented here docs?

Thread Previous | Thread Next
From:
Smylers
Date:
July 4, 2016 07:55
Subject:
Re: Indented here docs?
Message ID:
20160704080736.GA22953@stripey.com
Matthew Horsfall (alh) writes:

> So far, it seems the changes I must make are:
> 
>   * Switch ~ to -

You initially chose <<~ to match Ruby's similar operator. It's been
pointed out that <<- is the Bash equivalent. So that's one reason each
way. Is there any reason for Bash trump Ruby in this regard?

For what it's worth, Bash's <<- strips all leading tab characters.
Ruby's <<~ strips the indentation of the least-indented line. So we
don't have quite the same behaviour as either of them.

However, Ruby's operator for a ‘traditional’ here-doc that doesn't strip
any indentation is, unfortunately <<-, which means:

• If we go with <<~, Bash users have to learn a different operator for
  indentation-stripping here-docs in Perl.

• If we go with <<-, Ruby users have to learn a different operator for
  indentation-stripping here-docs in Perl, and the operator they have to
  learn is the one they are used to for non-indentation-stripping
  here-docs.

• Anybody who uses both Bash and Ruby already has to deal with this and
  whichever we pick isn't going to make things worse!

Smylers

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About