The Perl snippet mark is really not a tag, but simply declares a place to insert some arbitrary Perl code. The code cannot be greater than one line in length; that is, any code that requires a `;' must go in a MICPerl and not a snippet. In fact, the `;' is optional in the snippet.
Most generally, the snippet is used to print some value to the page. This value may or may not be viewed by the final user. That is, it could be used in an HTML link or what not. The three tags differ in their output. The first ( [+ ... +] ) will HTML-escape the result of the Perl code; it is therefore almost always the right thing to use except in links. The second ( [- ... -] ) will URI-escape, so it is almost always the right thing to use in links (and not elsewhere). The third ( [= ... =] ) does not process the code's output and is rarely if ever appropriate.
Normally, code snippets will be inserted within an HTML document where
it is advantageous to maintain the look of the document, yet there is
some variable fragment which needs to be resolved at run-time (when a
user actually views the page). For example, one might have something
like:
Hello [+ $name +], how are you doing today?or
<a href=http://[- $server || $default -]/face.html?flag=[- $flag -]>
Two notable limitations of the snippet are that commenting them out in any fashion will not prevent the code within from being executed, and that each snippet must be contained entirely on one line.
Note that since the [- ... -] snippet will URI escape, it cannot be used for the entire value of an href tag as it will likely screw up. `?' and `&' specifically will both be messed up.