Scott Penrose wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

sounds good to me. Anybody has an experience of using Filter::Simple with mod_perl?


A simple version looks like this...

package Apache::compat::uber;
use strict;
use Filter::Simple;

use constant ahh => 0;

FILTER {
    print STDERR "PRE = $_\n" if ahh;

s/localaddr/localaddr_compat/g;

    print STDERR "POST = $_\n" if ahh;
};

1;

And thats it... of course you have to write localaddr_compat in the Apache::compat module.

(mind you, this is untested :-)


What perl versions Filter::Simple is working with? Assuming that someone will need to use this trickery to get the same code working with mod_perl 1.0 and mod_perl 2.0?


Filter::Simple works with 5.6+

Thanks Scott, I'll give it a try.


2) Operator Overload
    use Apache::compat;
    # or what ever it actually is...
    print STDERR sockdaddr_in($r->localaddr);
    print STDERR $r->localaddr->ipnumber;
$r->localaddr returns an operator overloaded object which can then
check if we are returning a scalar (return the packed local address) or
are we returning a blessed reference (return the normal blessed
reference). I use this approach for code like this.
    print $md->DC->Title . "\n";
    print $md->DC->Title->Short . "\n";


How do you cope with a situation like this:

my $title = $md->DC->Title;

which can then be:

print $title;

or:

print $title->Short;


Both work, because in the first case it will be stringified to the actual title.
(although, sometimes you have to do print "" . $title;


In the second it will request from the overload method a blessed reference.

of course you can overload the "" operator so it'll magically work because print calls "". Is that what you meants by your example?


Yes :-) note to self, read bottom before replying above :-)

;)


It aint perfect. The Filter::Simple would probably be more reliable.

It also won't work in the case of APR::URI::unparse which has a different problem. It'd be nice to have a generic solution.


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com



Reply via email to