Overview Download Installation Docs Tutorial Credits Page Source Hosted by: Convolution |
Choose: PLP PLP::Functions PLP::Fields PLP::FAQ PLP::HowTo NAMEPLP::HowTo - Some examples of commong web things in PLP.
HOW TO...Additional Perl functionality is often available in modules. All of the modules used in this document are available (for free) at CPAN: http://search.cpan.org/
send a cookie
<:
get a cookie
Your user ID is <:= $cookie{ID} :>
set a header
<:
use a databaseUse DBI, and alternatively, one of the many simplifying modules. Drivers for DBI are in the DBD:: namespace. DBI loads the driver automatically, but it has to be available. If you need a fast full-featured file-base database, use DBD::SQLite, it's the instant database :).
<:
allow a user to upload a fileUse CGI.pm, which can be used with CGI::Upload to make things easier
<:
download a file into a variable
<:
implement basic authenticationThis only works with PLP under mod_perl. For CGI installations, it's useless.
<:
BEGIN {
my ($type, $login) = split / /, $r->header_in('Authorization');
unless ($user eq 'foo' and $pass eq 'bar') { (It is possible to use something similar with CGI, but it's not easy. Headers are communicated to your script via %ENV, and having credentials in there would be insecure, so Apache removes them. To get $ENV{HTTP_AUTHORIZATION}, you need to recompile Apache with -DSECURITY_HOLE_PASS_AUTHORIZATION, or use mod_rewrite to set the environment variable. Short answer: just use mod_perl.)
FEEDBACK
If you have good, simple examples of how to do common things with PLP, please
send them!
| |