|
Technical answers from the trenches |
|
Perl: Here Document Trap
| ||||
Posted: 10 September 2000 |
||||
  |
Applies to: Perl 5.x |
|||
  |
Audience: Beginner |
|||
If you use perl to dynamically create web pages and use Here documents to compose those pages, you need to be aware of an important subtlety. Here documents follow the same interpolation rules as print() and other functions. Here documents are interpolated by default and this can lead to strange and hard to fix 500 errors. To prevent interpolation in your here documents, declare them using single-quotes, as shown in the following example: print <<'__EOD__MARKER__'; To recap, declaring a here document like this: print <<__EOD__MARKER__; print <<"__EOD__MARKER__"; This is documented in the perldata man page, though it can be hard to find. The relevant section can be found by searching for "here-doc" (note the hyphen). If you're having troubles with your Here documents, try declaring them without interpolation. |
|||
|
||||||||
|
Copyright © 2000-2004, techtricks.com; All Rights Reserved. Acknowledgements, Disclaimers, Terms and Conditions. |
||||||||
|
Article last updated on 31 May 2003
|
||
|
|
||
|
[- End -]
|