From: Scott Penrose <[EMAIL PROTECTED]> To: Stas Bekman <[EMAIL PROTECTED]>
I have two solutions for your problem you presented yesterday. Both have side effects but I can work them at least in part (I don't know all the gotchas with ModPerl though).
1) Filter::Simple
use Apache::compat::uber;
# or what ever it actually is... print STDERR sockdaddr_in($r->localaddr);
no Apache::compat::uber;
print STDERR $r->localaddr->ipnumber;
will get converted to this
print STDERR sockaddr_in($r->localaddr_compat);
print STDERR $r->localaddr->ipnumber;
This has the side effect of having to do a Filter stage which is slower start up (but not much) and you have to get the regular expression right, but that won't be hard.
Sounds good to me. Anybody has an experience of using Filter::Simple with mod_perl?
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?
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;
of course you can overload the "" operator so it'll magically work because print calls "". Is that what you meants by your example?
__________________________________________________________________ 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