Listing 1. A bare-bones mason.pl
package HTML::Mason;
# Bring in Mason objects
use HTML::Mason;
# Always "use strict" in mod_perl
use strict;
# Create a Mason parser object
my $parser = new HTML::Mason::Parser;
# Create a Mason interpreter object, pointing to<\n>
# the component and data directories
my $interp = new HTML::Mason::Interp
(parser => $parser,
comp_root => '/usr/local/apache/mason',
data_dir => '/usr/local/apache/masondata/');
# Create an Apache handler
my $ah = new HTML::Mason::ApacheHandler (interp => $interp);
# Make sure that files are written as user
# "nobody"
chown ( [getpwnam('nobody')]->[2],
[getgrnam('nobody')]->[2], $interp->files_written );
# Create a basic "handler" subroutine
sub handler
{
# Get the Apache request object
my ($r) = @_;
# Handle the request
$ah->handle_request($r);
}
1;
Copyright © 1994 - 2019 Linux Journal. All rights reserved.