in reply to quotes in Perl
Very nice, concise overview. A couple of additional notes to keep in mind regarding here docs:
print << "ENDTAG"; # works print << 'ENDTAG'; # works print << ENDTAG; # syntax error!
Indented code block (same output as above)print "printing here doc:\n"; print <<"ENDTAG"; This text has 0 leading spaces This text has 4 leading spaces ENDTAG OUTPUT: printing here doc: This text has 0 leading spaces This text has 4 leading spaces
But, if the printed text includes leading whitespace, spaces can be included as part of the end tag to clean up the code block:{ print "printing here doc:\n"; print <<"ENDTAG"; This text has 0 leading spaces This text has 4 leading spaces ENDTAG }
{ print "printing here doc:\n"; print <<" ENDTAG"; This text has 4 leading spaces ENDTAG } OUTPUT: printing here doc: This text has 4 leading spaces
|
---|