[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: mod_perl and CGI::Application.. Strange Behaviour


Unless I'm missing sth, have you read the docs?

With CGI::Application, you don;t print anything, you just return whatever it is you want 'printed'

Dileep Eduri <suppressed> wrote:

I have able to solve to maximum extent.
rectified all the errors and able to print the result. this time its
printing the http headers as well....if I turn of http headers, then nothing
is getting printed..little weird !!!

modified my httpd conf file as follows:

Config File Entry

Alias /perl /docroot/cgi-perl
PerlModule Apache::Registry

SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI


and changed the perl module as follows:

Perl Module => First.pm

package First ;
use strict;
use base 'CGI::Application';
use CGI::Application::Plugin::Apache qw(:all);

sub setup {

my $self = shift;
$self->run_modes( 'mode1' => 'mode1_sub' );
$self->start_mode( 'mode1' );
}

sub mode1_sub {

my $self = shift;
my $req = $self->query();
$req->content_type( 'text/html' );
$req->send_http_header;

my $var = "Hello!!! Its Working
";
$req->print( $var );
}

1;

my CGI Script => first.cgi

use strict;
use First;

my $webapp = First->new();
$webapp->run();

Result

Its printing in browser along with headers as follows:

Hello!!! Its Working
HTTP/1.1 200 OK Date: Fri, 26 Oct 2007 19:45:18 GMT Server: Apache/1.3.33
(Darwin) PHP/4.3.9 mod_perl/1.26 Keep-Alive: timeout=15, max=98 Connection:
Keep-Alive, Keep-Alive Transfer-Encoding: chunked, chunked Content-Type:
text/html

I dont want to print headers so that only HTML content is shown...if I tried
to comment $req->send_http_headers; line in perl module, then nothing is
seen in the browser.

unable to figure out solution. Please help me



Dileep Eduri wrote:
>
> Hi everyone,
>
> Recently I have ported my Apache server to mod_perl and the server is
> working fine. I can say this by checking the error log and it says:
>
> [Fri Oct 26 10:52:16 2007] [notice] SIGHUP received. Attempting to
> restart
> [Fri Oct 26 10:52:17 2007] [warn] module mod_php4.c is already added,
> skipping
> [Fri Oct 26 10:52:17 2007] [notice] Apache/1.3.33 (Darwin) PHP/4.3.9
> mod_perl/1.26 configured -- resuming normal operations
> [Fri Oct 26 10:52:17 2007] [notice] Accept mutex: flock (Default: flock)
>
> And I am running this Apache on MAC. The entries for mod_perl in
> httpd.conf is as follows:
>
> Alias /perl /docroot/cgi-perl
> PerlModule Apache::Registry
>
> SetHandler perl-script
> PerlHandler Apache::Registry
> PerlSendHeader On
> Options +ExecCGI
>

>
> Problem
>
> I am trying to create mod_perl based appln using CGI::Application and I am
> just printing a message. Here is the Perl Module Test.pm, which will be
> loaded.
>
>
> package Test ;
> use strict;
> #our @ISA = qw[ CGI::Application ];
> use base 'CGI::Application';
>
> sub setup {
>
> my $self = shift;
> $self->run_modes( 'mode1' => 'mode1_sub' );
> $self->start_mode( 'mode1' );
>
> }
>
> sub mode1_sub {
>
> my $self = shift;
> my $req = $self->query();
>
> $req->content_type( 'text/html' );
> $req->send_http_header;
>
> return "using CGI::Application and mod_perl";
> }
>
> 1;
>
> Here is my CGI Script test.cgi:
>
> use strict;
> use lib '/docroot/cgi-perl/test';
> use Test;
>
> my $webapp = Test->new();
> $webapp->run();
>
> Both the CGI script and the module are in same directory. I am getting
> following error message in my error log and I am just could not
> understand, where I am doing wrong.
>
> [Fri Oct 26 11:05:39 2007] [error] Can't locate object method "new" via
> package "Test" at /docroot/cgi-perl/test/test.cgi line 5.\n
>
> Please guide me in this regard and it will be great help for my
> application.
>
> Thanks.
>

--
View this message in context: http://www.nabble.com/mod_perl-and-CGI%3A%3AApplication..-Strange-Behaviour-tf4697759.html#a13434311
Sent from the mod_perl - General mailing list archive at Nabble.com.




Disclaimer: Technically, I'm always wrong!!


For email that puts you in control, choose Yahoo! Mail.

Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.