You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Philip M. Gollucci" <ph...@p6m7g8.com> on 2002/01/09 18:33:19 UTC
mod_perl : HELP (am I going nuts ?)
The following short test script :
#!/usr/local/bin/perl
use strict;
use Apache;
my $r = shift;
my %params = $r->method eq 'POST' ? $r->content : $r->args;
$r->send_http_header('text/html');
print "Name = [", $params{'Name'}, "]<br />";
print "R = [" , $r, "]<br />";
print "Mehtod = [", $r->method, "]<br />";
print "Content = [", $r->content, "]<br />";
print "Args = [", $r->args, "]<br />";
Now lets say I goto http://www.dev.p6m7g8.com/perl-reg/test.pl?Name=p6m7g8
which is the above file
Gives output :
Name = []
R = [Apache=SCALAR(0x80d3aac)]
Mehtod = [GET]
Content = []
Args = []
Comming from CGI.pm, I know you can pass parameters like the Name(above) for
urls, but with mod_perl (aka Apache::*) All I can get at are variables inside
<form></form> in an html page.
Am I missing something, am I going nuts ?
PLEASE PLEASE TELL ME WHAT I AM NOT DOING RIGHT HERE !
Thanks in advance for all you kind souls out there!
I have read almost all of but most especialy
http://perl.apache.org/guide/snippets.html#CGI_params_in_the_mod_perl_ish_
If I need to read something else please point me there
My System configuration follows:
uname -a
FreeBSD sduwebship.student.umd.edu 4.4-RELEASE FreeBSD 4.4-RELEASE #0: Tue Jan
8 03:41:06 GMT 2002
philip@sduwebship.student.umd.edu:/usr/src/sys/compile/WEBSHIP i386
perl -v
This is perl, v5.6.1 built for i386-freebsd
Apache/1.3.22 (Unix) mod_python/2.7.6 Python/2.1.1 PHP/4.0.6 mod_perl/1.26
mod_ssl/2.8.5 OpenSSL/0.9.6b
httpd.conf [snipped]
PerlRequire /usr/local/www/apache/conf/startup.pl
<Location /perl-status>
SetHandler perl-script
PerlHandler Apache::Status
order deny,allow
deny from all
allow from .student.umd.edu
</Location>
Include conf/vhosts.conf
conf/vhosts.conf [snipped]
##### START MOD_PERL #####
Alias /perl-reg/ /usr/local/sites/dev/perl-reg/
PerlModule Apache::Registry
<Location /perl-reg>
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
allow from all
PerlSendHeader On
</Location>
startup.pl [entirety]
use strict;
# Make sure we are in a sane environment.
$ENV{MOD_PERL} or die "not running under mod_perl!";
# For things in the "/perl-reg" and "/perl-run" URL
use Apache::Status ();
use Apache::Registry;
use Apache::PerlRun;
# Load Perl modules of your choice here
# This code is interpreted *once* when the server starts
use LWP::UserAgent ();
use Apache::Status ();
use Apache::DBI ();
use DBI ();
$Apache::DBI::DEBUG = 2;
# Tell me more about warnings
use Carp ();
$SIG{__WARN__} = \&Carp::cluck;
# Load CGI.pm and call its compile() method to precompile
# (but not to import) its autoloaded methods.
use CGI ();
CGI->compile(':all');
Apache::DBI->connect_on_init
("DBI:mysql:database=test;host=localhost",
"test","xxxx",
{
PrintError => 1, # warn() on errors
RaiseError => 1, # die on error
AutoCommit => 1, # commit executes immediately
Taint => 1 # Taint Checking on
}
);
1;
------------------------------------------------------------------------------
Philip M. Gollucci (p6m7g8) philip@p6m7g8.com 301.314.3118
Science, Discovery, & the Universe (UMCP)
Webmaster & Webship Teacher
URL: http://www.sdu.umd.edu
EJPress.com
Database/PERL Programmer & System Admin
URL : http://www.ejournalpress.com
Resume : http://www.p6m7g8.com/resume.txt