#!/usr/bin/perl -w
use strict;
# ---------------------------------------------------------
# Heres an example of the code in a script that uses PCOM
# ---------------------------------------------------------
# you have to "use PCOM;" to use PCOM
# (sorry about that, just couldn't resist.)
use PCOM;
# make a new PCOM class object
my($pcobj) = PCOM->new();
# create a data communications
# repository with the new PCOM class
# object
my($pcom) = $pcobj->main();
# get present working directory
my($pwd) = $pcom->{'PWD'};
# get script name and current namespace.
# namespace retrieval is very
# helpful when running under mod_perl
my($script) = $pcom->{'SCRIPT'};
my($packg) = $pcom->{'PACKAGE'};
# we can retrieve ENVironment variables
# and share them with class objects
# by passing the $pcom data repository
# over to the objects that need it
my($qstr) = $pcom->{'REMOTE_ADDR'};
# ...and same for ARGV
my(@argv) = @{ $pcom->{'ARGV'} };
# you can add information to a pcom object
$pcom->{'PATHS'} = {
'cgi' => $pcom->{'PWD'},
'htdocs' => '.',
'root' => $pcom->{'PWD'},
};
# stuffing your important directory locations
# into $pcom lets you share that important
# information with any class objects to which
# you pass a $pcom
$pcom->{'DIRS'} = {
'htdocs' => $pcom->{'PWD'},
'modules' => $pcom->{'PWD'}.'/../modules',
'include' => $pcom->{'PWD'}.'/../../include',
'objects' => $pcom->{'PWD'}.'/../../objects',
'templates' => $pcom->{'PWD'}.'/templates',
'errors' => $pcom->{'PWD'}.'/../templates/errors',
'logs' => $pcom->{'PWD'}.'/logs',
'defs' => $pcom->{'PWD'}.'/../../defs',
'ad_images' => $pcom->{'PWD'}.'/img/ad_banners',
};
# pass the pcom object and all its information
# to modules or other namespaces which otherwise
# couldn't get access to all of it themselves without
# some very inordinate amount of work and some
# completely blind guessing
my($p) = Some::Module->new('pcom' => $pcom);
# now the $p object knows all of the environment vars
# the directory structure it sits in, @ARGV, and a
# whole lot of other stuff including any information
# you added to the object yourself.