ibm1620 has asked for the wisdom of the Perl Monks concerning the following question:
The here-doc modifier ~ allows you to indent your here-docs to make the code more readable:It's not obvious to me what "the delimiter" is and how was it declared. To me, it's an odd use of the word "delimiter".This will print...if ($some_var) { print <<~EOF; This is a here-doc EOF }...with no leading whitespace.This is a here-docThe delimiter is used to determine the exact whitespace to remove from the beginning of each line.
Am I correct in assuming that what's meant is: when you write "<<~EOF;", Perl will take the initial whitespace characters from the following line as an "indentation definition" and remove it from the beginning of every line in the here-doc?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: indented here-doc "delimiter"
by LanX (Saint) on Apr 14, 2018 at 00:33 UTC | |
by ibm1620 (Hermit) on Apr 14, 2018 at 01:29 UTC | |
by LanX (Saint) on Apr 14, 2018 at 06:59 UTC | |
by soonix (Chancellor) on Apr 14, 2018 at 07:39 UTC | |
by LanX (Saint) on Apr 14, 2018 at 09:20 UTC | |
|
Re: indented here-doc "delimiter"
by trippledubs (Deacon) on Apr 14, 2018 at 01:52 UTC | |
|
Re: indented here-doc "delimiter"
by Anonymous Monk on Apr 14, 2018 at 08:54 UTC | |
|
Re: indented here-doc "delimiter"
by Anonymous Monk on Apr 14, 2018 at 08:20 UTC |