cleanup (minor things like punctuation, use spaces for docu indenting)
[perl/plp/.git] / PLP / HowTo.pod
1 =head1 NAME
2
3 PLP::HowTo - Some examples of commong web things in PLP.
4
5 =head1 HOW TO...
6
7 Additional Perl functionality is often available in modules. All of the modules
8 used in this document are available (for free) at CPAN: http://search.cpan.org/
9
10 =head2 send a cookie
11
12  <: 
13      BEGIN {
14          use CGI::Cookie;
15          AddCookie(
16              CGI::Cookie->new(
17                  -name => 'ID',
18                  -value => 123456,
19                  -domain => 'foo.com',
20                  -path => '/'
21              )->as_string
22          );
23      }
24  :>
25
26 =head2 get a cookie
27
28  Your user ID is <:= $cookie{ID} :>
29
30 =head2 set a header
31
32  <:
33      BEGIN {
34          $header{Content_Type} = 'text/plain';
35      }
36  :>
37
38 =head2 use a database
39
40 Use DBI, and alternatively, one of the many simplifying modules. Drivers for
41 DBI are in the DBD:: namespace. DBI loads the driver automatically, but it has
42 to be available.
43
44  <:
45      use DBIx::Simple; # and read its documentation for examples.
46  :>
47
48 =head2 allow a user to upload a file
49
50 Use CGI.pm, which can be used with CGI::Upload to make things easier
51
52  <:
53      use CGI;         # and don't use %post in your PLP document.
54      use CGI::Upload; # and read its documentation for examples.
55      my $cgi = CGI->new;
56      my $upload = CGI::Upload->new($cgi);
57      ...
58  :>
59
60 =head2 download a file into a variable
61
62  <:
63      use LWP::Simple;
64      my $page = get 'http://foo.com/bar.html';
65  :>
66
67 =head1 FEEDBACK
68
69 If you have good, simple examples of how to do common things with PLP, please
70 send them! <juerd@cpan.org>
71
72 =cut
73