File tree Expand file tree Collapse file tree 1 file changed +43
-1
lines changed Expand file tree Collapse file tree 1 file changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -212,7 +212,49 @@ execute external commands.
212
212
213
213
= head2 Heredocs: :to
214
214
215
- TODO
215
+ A convenient way to write multi-line string literals are I < heredocs > , which
216
+ lets you chose the delimiter yourself:
217
+
218
+ = begin code
219
+ say q:to/END/;
220
+ Here is
221
+ some multi line
222
+ string
223
+ END
224
+ = end code
225
+
226
+ The contents of the heredoc only begin on the next line, so you can (and
227
+ should finish the line).
228
+
229
+ = begin code
230
+ my $escaped = escaque(q:to/TERMINATOR/, language => 'html');
231
+ Here are the contents of the heredoc.
232
+ Potentially multiple lines.
233
+ TERMINATOR
234
+ = end code
235
+
236
+ If the terminator is indented, that amount of indention is removed from the
237
+ string literals.
238
+
239
+ = begin code
240
+ say q:to/END/;
241
+ Here is
242
+ some multi line
243
+ string
244
+ END
245
+ = end code
246
+
247
+ which produces
248
+
249
+ = begin code
250
+ Here is
251
+ some multi line
252
+ string
253
+
254
+
255
+ = end code
256
+
257
+ Heredocs include the newline from before the terminator.
216
258
217
259
= head1 Regexes
218
260
You can’t perform that action at this time.
0 commit comments