cvsuser 02/02/08 07:31:22
Added: P5EEx/Blue/cgi-bin config.pl.sample p5ee.PL
Removed: P5EEx/Blue/cgi-bin p5ee p5ee.pl.sample
Log:
substitute interpreter line on install and ensure that file names don't conflict
Revision Changes Path
1.1 p5ee/P5EEx/Blue/cgi-bin/config.pl.sample
Index: config.pl.sample
===================================================================
$data = {
#########################################################################
# $Id: config.pl.sample,v 1.1 2002/02/08 15:31:22 spadkins Exp $
# NOTE: this is after the "$data = {" line for a reason
#########################################################################
};
1.1 p5ee/P5EEx/Blue/cgi-bin/p5ee.PL
Index: p5ee.PL
===================================================================
use Config;
use File::Basename qw(basename dirname);
chdir(dirname($0));
($file = basename($0)) =~ s/\.PL$//;
$file =~ s/\.pl$//
if ($Config{'osname'} eq 'VMS' or
$Config{'osname'} eq 'OS2'); # "case-forgiving"
open OUT,">$file" or die "Can't create $file: $!";
chmod(0755, $file);
print "Extracting $file (with variable substitutions)\n";
print OUT <<"!SUBSTITUTIONS!OK!";
$Config{'startperl'} -wT
!SUBSTITUTIONS!OK!
print OUT <<'!NO!SUBSTITUTIONS!';
#############################################################################
# $Id: p5ee.PL,v 1.1 2002/02/08 15:31:22 spadkins Exp $
#############################################################################
BEGIN {
my ($var, $value, $open, $file);
local(*FILE);
%main::conf = ();
$open = 0; # assume we cannot find an openable config file ...
if (defined $ENV{PATH_INFO}) {
$file = $ENV{PATH_INFO} . ".conf"; # default config file based on PATH_INFO
$file =~ s!^/!!; # with no leading "/"
$file =~ s!/!_!g; # and internal "/"s changed to "_"s
$open = open(main::FILE, "< $file") if (-r $file);
}
$open = open(main::FILE, "< $0.conf") if (!$open && -r "$0.conf");
$open = open(main::FILE, "< p5ee.conf") if (!$open && -r "p5ee.conf");
if ($open) {
while (<main::FILE>) {
chomp;
s/#.*$//; # delete comments
s/^ +//; # delete leading spaces
s/ +$//; # delete trailing spaces
next if (/^$/); # skip blank lines
# look for "var = value" (ignore other lines)
if (/^([a-zA-Z_.-]+) *= *(.*)/) { # untainting also happens
$var = $1;
$value = $2;
$main::conf{$var} = $value; # save all in %main::conf
}
}
close(main::FILE);
if (defined $main::conf{perlinc}) { # add perlinc entries
unshift(@INC, split(/ *, */,$main::conf{perlinc}));
}
}
}
#################################################################
# read command-line configuration variables
# (anything starting with one or two dashes is a config var, not a CGI var)
# i.e. --debugmode=record -debugmode=replay
# an option without an "=" (i.e. --help) acts as --help=1
#################################################################
while ($#ARGV >= 0 && $ARGV[0] =~ /^--?([^=-][^=]*)(=?)(.*)/) {
$var = $1;
$value = ($2 eq "") ? 1 : $3;
shift @ARGV;
$main::conf{$var} = $value;
}
use P5EEx::Blue::P5EE;
#################################################################
# NOTE: some Context classes (e.g. Context::CGI) also read in
# the environment and store it in the %main::conf.
#################################################################
my $context = P5EEx::Blue::P5EE->context(\%main::conf);
$context->dispatch_events();
!NO!SUBSTITUTIONS!