Hello

I'm a little new to embperl.  I have a friend who uses it alot.

My problem is that I need to get my modperl module to work with embperl.

The module is simple.  It just changes on the fly the BASE HREF tags from one
site to another so that we don't have to hard ocde the canges.  It looks like 
this:

package Apache::CHANGE_BASE;
use strict;
use Apache::Constants qw(:common);
use Apache::File ();

sub handler{
        my $r = shift;
        print STDERR "IN THE MODULE\n";
        if ($r->content_type() ne 'text/html'){
                print STDERR "THis is not an html file\n";
                return DECLINED;
                print STDERR "This shouldnt Happen\n";
        }
        print STDERR "OK - We have an HTML File\n";
        my $filename = $r->filename;

        unless( -e $r->finfo){
                $r->log_error('$file Does Not Exist');
                return NOT_FOUND;
        }

        unless(-r _){
                $r->log_error("File Access Denied to $filename");
                return FORBIDDEN;
        }

        my $fh;
        if(!($fh = Apache::File->new($filename))){
               $r->log_error("File not open for reading: $!");
               return 'SERVER_ERROR';
        }
        $r->send_http_header;

        while(<$fh>){
                if(/<BASE HREF/i){
                        print STDERR "We have a match\n";
                        s{www\.inns\.net}{inns\.mrbrklyn\.com}io;
                }
                $r->print($_);
        }

        return OK;
}

1;


Then I need to run the same fles through embperl.  Doing research, I've learned I need 
to chain
the modules so that the output of one calls the other.

iI've tried Apache::OutputChain EmbperlChain, and I'm not getting expected results.

First I tried to put it into a location with the following setup in the httpd.conf 
file.  This
caused a failure with the indexing of directories.  Apache sent back no data.  Then I 
set it up
woth a File tag like this:

<VirtualHost 216.254.112.136>
    ServerAdmin [EMAIL PROTECTED]
    DocumentRoot /usr/local/apache/htdocs/inns
    ServerName inns.mrbrklyn.com
    ErrorLog logs/www.inns-error_log
    CustomLog logs/www.inns-access_log common
        <LOCATION "/">
        Options Indexes FollowSymLinks MultiViews ExecCGI
            AllowOverride None
            Order allow,deny
            Allow from all
        </LOCATION>
        <Files *.html>
               SetHandler perl-script
                PerlHandler Apache::OutputChain Apache::CHANGE_BASE 
Apache::EmbperlChain
        </Files>

        <LOCATION "/images">
                SetHandler none
        </LOCATION>

</VirtualHost>


Now I get the Base name tags changing on the fly, but the embperl still fails to work. 
 I've tried to
debug the actual EmbperlChain and OutputChain modules and I'm stuff figuring out 
anything more.

The error logs are coming up like this:

In OutputChaini class is
    Apache::OutputChain tied Apache::OutputChain -> Apache
    Apache::OutputChain::TIEHANDLE ARRAY(0x83b2e64)
    Apache::OutputChain::TIEHANDLE ARRAY(0x83dd86c)
IN THE MODULE
OK - We have an HTML File
Reached EMBPERLCHAIN Last in Chain
This is the File and the Handler 
/usr/local/apache/htdocs/inns/addmysite/addmysite_02.html Apache=SCALAR(0x84eb570)
In OutputChaini class is Apache::EmbperlChain
    Apache::OutputChain tied Apache::EmbperlChain -> Apache::OutputChain
    Apache::OutputChain::TIEHANDLE ARRAY(0x826e8bc)
    Apache::OutputChain::TIEHANDLE ARRAY(0x83f09d8)
[Wed Apr  3 17:50:02 2002] [error] [client 216.254.112.135] Invalid method in request 
name=&innkeeper_01_name=&innkeeper_02_name=&innkeeper_03_name=&company_website=http%3A%2F%2F&name_of_inn=&address1=&address2=&city=&Selection2=Please+select&zip=&Selection=Please+Select&email=&email_confirm=&telephone=&telephone_toll_free=&fax=GET
 /addmysite/btn_help.gif HTTP/1.1
[Wed Apr  3 17:50:02 2002] [error] [client 216.254.112.135] File does not exist: 
/usr/local/apache/htdocs/inns/addmysite/background_wi.gif

Does anyone have success doing this.  This has to be a common thing to happen.


David




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to