10.5. Embperl Commands

As we saw earlier, Embperl commands start with a “[” and end with a “]”. Because “[” has a special meaning, to put a “[”on your web page, you must write it as “[[”.

10.5.1. [+ Perl Code +]

The code within [+ ... +] is executed, and the result is that the command is replaced with what the code evaluates to. Thus [+ "hello!" +] is the same as print "hello!" in a normal CGI program. For example:

<p>Hello [+ $name +]</p> 

If the value of $name is “Gerald Richter”, the result of the previous command after Embperl is through processing it is this:

<p>Hello Gerald Richter</p> 

A command can contain any Perl expression, including array elements, hash elements, and function calls:

 [+ $i+1 +] [+ $a[$i] +] [+ $info{name} +] [+ ...

Get Open Source Web Development with LAMP: Using Linux, Apache, MySQL, Perl, and PHP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.