PSL Here Documents


A here document is a free-form string that is not modified by the PSL compiler. Special characters like \n (new line) and \t (tab), that are used to control output format in strings, are not interpreted when they are contained in here document constructions.

The here document construction starts with <<< followed by a string that will be used as the here document text delimiter. The here document text string continues until the delimiter is repeated at the beginning of a line. The here document delimiter can be any string consisting of letters, numerals, and underscores (_), without internal blanks.

The here document construction can be used anywhere that a variable or string can be used, or it can be assigned to a variable. This is shown in the following example:

here_document= <<<Here_Doc_DELIMIT
This is a free-form string.
Special characters like \n are not translated.
However, they would be in a quoted string.
This here document will continue until the delimiter
'Here_Doc_DELIMIT' is found at the beginning of a line.
That means the above 'Here_Doc_DELIMIT' was not the end.
The next line is the end delimiter, not part of the string.
Here_Doc_DELIMIT;
print(here_document);


This example returns the following output: 

This is a free-form string.
Special characters like \n are not translated.
However, they would be in a quoted string.
This here_document will continue until the delimiter
'Here_Doc_DELIMIT' is found at the beginning of a line.
That means the above 'Here_Doc_DELIMIT' was not the end.
The next line is the end delimiter, not part of the string.

Everything between the two delimiters, for example in the preceding example here_Doc_DELIMIT represents the here document variable text string.

Where to go from here

PSL-Data-Types-and-Objects 

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*