here-documents in Perl

May 24, 2008

Here-documents are something that, once you know about them, you wonder how you ever got along without. I first learned about here-docs in Python many years ago, but didn’t know their proper name. In Python, you define a here document with three single or double quotes:

Note the use of quotes for the string-terminating sentinel (EOF, in this case, though it can be anything), which affects how the sting is interpreted. Just like with other strings in Perl, double-quotes mean that variables and escapes will be interpreted whereas they are ignored in single-quoted strings.