in reply to Printing without escaping quotes
But that's even worse than a here-doc. Fortunately, 90% of all cases where I want multiline string constants, it's about a piece of HTML. And HTML parsers don't really care about whitespace.my $foo = 'First line Second line Third line';
That looks a lot better. But there's another problem:my $foo = ' First line<br> Second line<br> Third line<br> ';
Some people love backslash escapes, but I hate to escape my delimiter. But perl can handle alternative delimiters. '' is q// and "" is qq//. Instead of /, any non-whitespace character can be used (note: if the character is alphanumeric, whitespace is _required_ after the operator's letters (q mfoom eq 'foo'). You can use grouping characters (() [] {} [] <>) and perl will keep track of nesting.my $foo = " First line<br> $second_line<br> <a href=\"foo.html\">Third line</a> ";
my $foo = qq{ First line<br> $second_line<br> <a href="foo.html">Third line</a> };
|
|---|