I need to write down a complicated MySQL query in perl.
I want to structure it in multiple lines.
Unfortunately,when using EOF notation perl inserts \n into my string.
Is there a way to write down a String in multiple lines, so that perl wont insert \n in it?
I eithr do not want to explicetly concat each line by a +.
No, but you can easily remove the lines after-the-fact. For example, this:
will print this:
Edited to add:
A few things to note about the above:
my-expression in parentheses; the variable is still scoped to the enclosing block.A
my-expression evaluates to the variable that it declares, and you can continue to modify that variable. For example:The heredoc notation
<<starts the heredoc (the multiline string) on the following line. For example:In fact, this is actually very common; it’s slightly unusual for
<<EOFto be the very last thing on the line, because if nothing else, there’s usually a semicolon after it to indicate the end of the statement.If you have multiple heredocs on the same line, then each one starts on the line after the previous one ends: