proper use of mod_perl2

Martín Ferrari martin.ferrari at gmail.com
Tue Feb 5 00:46:21 UTC 2008


Hi Amir,

On Feb 4, 2008 10:00 PM, Amir Tabatabaei <amirovic at googlemail.com> wrote:

First of all, I think this is not the right list, as it is for
development of Debian packages of perl libraries.

> I'd like to switch from PHP to perl for further web developments. After
> installing libapache2-mod_perl2 and asking $search_engine for its usage
> - as I could not find any information on this in any document provided
> by this package (Did I miss something?) - I added the following lines to
> my apache config file:

Check http://perl.apache.org/, it has lots of info about mod_perl.


>         PerlResponseHandler ModPerl::Registry

> I set the handler to the root apache directory as I'm planning to use
> perl files only without any pure html-file.
> Question: Is this the right way and syntax to do so? Any concerns?

::Registry is the usual way to use already written CGI code without
much modifications. But the powerful way of using mod_perl is to write
handlers, that is, libraries/modules that are called directly by
apache when a request is received, allowing you to access all apache
internals and communicating with it.

you usually will have a MySite/Foo.pm like this:

package MySite::Foo;

sub handler {
..
 return OK;
}

and in apache.conf

 PerlResponseHandler MySite::Foo

after loading your module with one of the various methods available.

> I'd like to have all files without any extension.
> Question: Any concerns or comments here?

it is ok as a CGI script.

> To find out more about mod_perl2 I installed libapache2-mod-perl2-doc.
> Stupid question: How do I use this package? Sorry, I'm quite new to perl
> and have no clue how the "config.cfg" or any other file
> in /usr/share/doc/libapache2-mod-perl2-doc/ can be used to get some
> useful information. I hoped to use a web-browser to see the
> documentation, but each file is either display as plain text or is
> offered for download.

The documentation is provided in POD format, use perldoc to read it.

> My last question is about how to write websites? Do I have to "print"
> every html line like I did in the example above? Is there a proper way
> of writing html code with perl? Links to howtos are very appreciated!

on "pure" mod_perl usage, you use the print method of Apache::Request.
But see the documentation from apache.org.

Good luck!

-- 
Martín Ferrari



More information about the pkg-perl-maintainers mailing list