O'Reilly logo

Open Source Web Development with LAMP: Using Linux, Apache, MySQL, Perl, and PHP by Brent Ware, James Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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} +] [+ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required