Hi,
I'm new to mod_perl and I'm trying to port a web application I had
running using java-servlets to perl (becouse I'm running a server on
a very old machine, and mod_perl is giving me excelent speeds). I've
read the mod_perl guide, specifically the section 5 (the mod_perl
guidelines), but I'm still having problems. It's a simple web-forum
(bbs) using DBI to access a mysql database.
I have two files:
index.perl -> in a web directory
AALC.pm -> in /var/www/perllib
This is my startup.pl file:
------
use strict;
use lib "/var/www/perllib";
$ENV{GATEWAY_INTERFACE} =~ /^CGI-Perl/ or die "GATEWAY_INTERFACE not Perl!";
use Apache::Registry ();
use CGI (); CGI->compile(':all');
use CGI::Carp ();
use DBI ();
use DBD::mysql ();
1;
------
In AALC.pm (which defines the package AALC) I've defined some global
variables and all of my methods (display info, query the database,
open files, etc). This is index.perl:
------
use AALC;
my $q = CGI->new or die $aalc_text{'eruk'};
my $forum_id = defined($q->param('forum')) ? $q->param('forum') : "";
my $msg_id = defined($q->param('msg_id')) ? $q->param('msg_id') : 0;
print $q->header('text/html');
if ($msg_id > 0)
{
AALC->show_message($msg_id);
return;
}
if ($forum_id ne "")
{
AALC->show_forum($forum_id);
return;
}
AALC->list_forums();
------
The problem I'm facing right now is that it works the first time. But
the second time I make a request to the database (when I pass a
$msg_id parameter) it won't work (it's like it's reading a wrong
parameter or not accessing the database). If I try to modify the
module AALC.pm (which has a 'use Apache::Reload', to not restart the
server each time) it dies with this error:
[error] Too many arguments for AALC::display_error at
/var/www/perllib/AALC.pm line 28, near "})"
which is stupid, because I didn't modify that line, and it was
working fine. This is line 28:
$sth = $dbh->prepare($query) or display_error($aalc_text{"erbd"});
In AALC.pm $query, $dbh, $sth and two other variables are defined as
locals (with 'my'). I just don't know what to do or where to start
looking for the error. Can anyone please point me in the right
direction?
thanks a lot,
--
Rolando Abarca
Estudiante Injenieria U. de Chile
rabarca (at) ing.uchile.cl - funk (at) andatealachucha.cl