Choose:
PLP
PLP::Functions
PLP::Fields
PLP::FAQ
PLP::HowTo

NAME

PLP::FAQ - Frequently Asked Questions about PLP

FAQ

  • What does PLP stand for?
  • PerlPage. The name used to be HTMPL, but HyperText Markup with Perl Language was too long.

  • Is PLP hard to install?
  • No, it actually is very simple and easy. Quick startup hints are in the PLP main documentation, extensive installation instructions are on the PLP website.

  • Is Perl code harder than PHP code?
  • Yes, it is. But when you get used to Perl, you will probably dislike PHP for the rest of your life. Perl is faster and far more powerful. For both Perl beginners and more advanced Perl coders, PerlMonks is a good Perl forum community. (Please note: PLP is not Perl. Perl is a complete programming language and is not restricted to web based applications. PLP uses Perl, but many people use Perl without PLP.

  • Can PLP be used with mod_perl?
  • Yes. As of 3.00, PLP can be used with mod_perl! And it's very fast!

  • You seem to promote dirty programming. Can I use strict with PLP?
  • PLP can be used for quick-and-dirty hacks in a way similar to PHP. However, it is suitable for larger applications as well. You can use strict if you want. mod_perl Users might like to know that globals are automatically destroyed (as long as you do not switch packages).

  • How can I make PLP faster?
  • With mod_perl or FastCGI, PLP is a lot faster than with CGI. Instead of executing a new perl process for each request, the same interpreter will serve multiple pages.

  • I already run persistently, can I make my scripts even faster?
  • Well, you already have scripts that probably are faster than PHP equivalents, but speed maniacs always want more. Modules are cached, so with a proper module design, you can add a little more speed.

  • Can I use Perl's CGI module with PLP?
  • You certainly can! If you do not want %get and %post and the like, just don't use them. They will be generated on first access, so if you never access them, the hashes are never filled.

    If you want to use CGI.pm's header functions, select STDOUT; first, to break out of PLP's tied PLPOUT filehandle.

  • Why does <($filename)> not work?
  • <(...)> is a compile-time tag, opposed to include(), which is evaluated at run-time. At compile time, variables are not yet known, and PLP will try to include a file literally called $filename.

        <: $filename = 'foo.inc.plp'; include($filename); :>

  • Why do my variables not work in my include()d file?
  • That is because your variable is lexical (declared with my), and the file is evaluated in its own scope, just as with Perl's built-in do and require. You can pass variables through subroutine parameters or by using globals variables. Another solution is using PLP's <(...)> tag.

  • But why do they work with <()> then?
  • Because it places the external file is placed inside of the other, before the code is executed (at compile-time).

  • Why do my END blocks never get executed?
  • These blocks are executed when the interpreter stops, which only occurs if you are running as CGI. To catch the exit of a PLP script, use PLP_END blocks instead. Please note that PLP_END is a normal statement, so you may need a semicolon.

        <html><body>
        <: PLP_END { :>
            </body></html>
        <: } :>
        contents

  • Can I disable the error messages?
  • You can not disable compile-time errors (syntax errors), but you can disable run-time errors. To do so, set the 0-bit (1) of $PLP::DEBUG off. If you only want error reporting disabled for a single command, use Perl's eval BLOCK function (not eval "", but eval {}, which is not slow or insecure.).

        <: $PLP::DEBUG &= ~1; :>

  • Can I have my own error messages?
  • Yes, you can! Of course, you can not override compile-time errors like syntax errors, but run-time error messages use $PLP::ERROR, which is a reference to a sub that gets two arguments: the error message itself, and an html-encoded version.

        <:
            $PLP::ERROR = sub {
                my ($plain, $html) = @_;
                print '<font color="red">', $html, '</font>';
            };
        :>

  • Is there a way to see the headers that PLP sends?
  • There is. Set $PLP::DEBUG's 1-bit (2), and it will output a plain text header before outputting the other one.

        <: $PLP::DEBUG |= 2; :>