PApp::PCode - PCode compiler/decompiler and various other utility functions.



PApp stores a lot of things in pcode format, which is simply an escaping mechanism to store pxml/xml/html/pelr sections inside a single data structure that can be efficiently converted to pxml or perl code.

You will rarely if ever need to use this module directly.

pxml2pcode ``phtml or pxml code''
Protect the contents of the phtml or pxml string (xml with embedded perl sections), i.e. make it an xml-parseble-document by resolving all <: and <? sections.

The following four mode-switches are allowed, the initial mode is ``:>'' (i.e. non-interpolated html/xml). You can force the initial mode to ``:>'' by prefixing the string with ``<:?>''.

 <:     start verbatim perl section ("perl-mode")
 :>     start plain string section (non-interpolated string)
 <?     start perl expression (single expr, result will be interpolated)
 ?>     start interpolated string section (similar to qq[...]>) DEPRECATED
        will soon mean the same as :>

Within plain and interpolated string sections you can also use the __``string'' construct to mark (and map) internationalized text. The construct must be used verbatim: two underlines, one double-quote, text, and a trailing double-quote. For more complex uses, just escape to perl (e.g. <?__``xxx''?>).

In string sections (and only there!), you can also use preprocessor commands (the # must be at the beginning of the line, between the # and the command name can be any amount of white space, just like in C!)

 #if any_perl_condition
   any phtml code
 #elsif any_perl_conditon

Preprocessor-commands are ignored at the very beginning of a string section (that is, they must follow a linebreak). They are completely removed on output (i.e. the linebreak before and after it will not be reflected in the output).

White space will be mostly preserved (especially line-number and -ordering).

xml2pcode ``string''
Convert the string into pcode without interpreting it.

perl2pcode ``perl source''
Protect the given perl sourcecode, i.e. convert it in a similar way as phtml_to_pcode.

pcode2perl $pcode
Convert the protected xml/perl code into vanilla perl that can be eval'ed. The result will have the same number of lines (in the same order) as the original perl or xml source (important for error reporting).


the PApp manpage.


 Marc Lehmann <>