-----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+


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.

Scooter
- -- Scott Penrose
Open source developer
http://linux.dd.com.au/
[EMAIL PROTECTED]


Dismaimer: Open sauce usually ends up never coming out (of the bottle).
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (Darwin)
Comment: For info see http://www.gnupg.org

iD8DBQE+6BCuDCFCcmAm26YRAhuhAKCItBmR+OSFq/yW6DCk9BeNDX8jJQCfR4m0
zmmgtPgUFEL+Uc7wxxwpAjo=
=AJUR
-----END PGP SIGNATURE-----



Reply via email to