[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [Fun With Perl] Package Retrofit



On Fri, Jun 11, 1999 at 10:50:16AM -0400, mjd-list-fwp@plover.com wrote:
> Another approach is to subclass Mozilla::LDAP::Entry, like this:
> 
> 	package Tricky::LDAP::Entry;
> 	@ISA = qw(Mozilla::LDAP::Entry);
> 
> 	$can_getLDIFrecords = can Mozilla::LDAP::Entry 'getLDIFrecords';
> 	sub new {
> 	  my ($package) = @_;
> 	  my $new = $package->SUPER::new(@_);
> 	  return $can_getLDIFrecords ? $new : bless $new => $package;
> 	}
> 
> 	sub getLDIFrecords { ... }

Problem: What if the class you're tinkering with is not the top level?
ie. What if you wanted to add a method to HTTP::Message (which is used
by HTTP::Headers).  I don't think simple overriding will cut it.

-- 

Michael G Schwern                                           schwern@pobox.com
                    http://www.pobox.com/~schwern
     /(?:(?:(1)[.-]?)?\(?(\d{3})\)?[.-]?)?(\d{3})[.-]?(\d{4})(x\d+)?/i

==== Want to unsubscribe from this list? (Don't you love us anymore?)
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org