mod_perl2 module
jonsmith1982
created: 2006-04-02 08:27:55
im trying to make a mod_perl module, but find that my script is very limited in its lay out, and cant figure out how to use the sub routines correctly. But my main problem at the moment is:-

use Apache2::RequestIO (); # for $r->puts(<<"END");

i would like to use cgi.pm forms and stuff after END which is filled with half a html template then use $r->puts(<<"END"); for the other half of the html template.

But the stuff in the middle (cgi.pm) doesnt display even if i use plain html instead of cgi.pm.

i have also tried print <
maybe because its in the middle of a table?>


here is the code:-

package Apache2::CPH;
use strict;
use Apache2::RequestRec ();  # for $r->content_type
use Apache2::RequestIO ();   # for $r->puts
use Apache2::Const -compile => ':common';
use CGI;






sub handler {
    

    my $q = new CGI;


    my $p = shift;
    my $time = scalar localtime();
    $p->content_type('text/html');
    my $uri = $p->uri;
    my $title = substr($uri, 1);
    if ($title =~ "home") {
	$title = "Home"
	}
    elsif ($title =~ "residential_mortgages") {
	$title = "Residential Mortgages" 
	}
    elsif ($title =~ "commercial_mortgages") {
	$title = "Commercial Mortgages" 
	}
    elsif ($title =~ "pensions") {
	$title = "Pensions" 
	}
    elsif ($title =~ "investments") {
	$title = "Investments" 
	}
    elsif ($title =~ "life_assurance") {
	$title = "Life Assurance" 
	}
    elsif ($title =~ "general_insurance") {
	$title = "General Insurance" 
	}
    elsif ($title =~ "contact_us") {
	$title = "Contact Us" 
	}
    else {
	$title = "Home"
	};


    my $content;

    if ($title =~ "Home") {
	$content = "Homepage"
	}
    elsif ($title =~ "Residential Mortgages") {
	   $content = "Residential Mortgages"
	}
    elsif ($title =~ "Commercial Mortgages") {
	   $content = "Commercial Mortgages"
	}
    elsif ($title =~ "Pensions") {
	   $content = "Pensions"
	}
    elsif ($title =~ "Investments") {
	   $content = "Investments"
	}
    elsif ($title =~ "Life Assurance") {
	   $content = "Life Assurance"
	}
    elsif ($title =~ "General Insurance") {
	   $content = "General Insurance"
	}
    elsif ($title =~ "Contact Us") {
	   $content = "Contact Us"
	};






$p->puts(<<"END");










$title







  


$time

$content

END print "© 2006 All Rights Reserved."; $p->puts(<<"END");
 
© 2006 C P H All Rights Reserved.
Website Designed by s1mon.
END return Apache2::Const::OK; }; 1;
Re: mod_perl2 module
created: 2006-04-02 08:38:55
if this is on a windows machine, put the following as the first executable line of code, which flushes buffers properly$| = 1;
the hardest line to type correctly is: stty erase ^H
Re^2: mod_perl2 module
created: 2006-04-02 08:48:11
i have tried $| = 1; and print "© 2006 All Rights Reserved."; still doesnt display.

it is a windows machine.
Re^3: mod_perl2 module
created: 2006-04-02 11:17:10
found a cure for my problem

END
$p->print($q->h1('hey'));
$p->print (<<'END');


the print function within Apache2::RequestIO (); allows me to use CGI.pm functions.
Re^2: mod_perl2 module
created: 2006-04-02 13:18:24

I downvoted this answer. Why do you think the OP had a buffering problem?

perlmonks.org content © perlmonks.org and Anonymous Monk, aquarium, chromatic, jonsmith1982

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03