[prog] Perl decorator classes

Dan Richter daniel.richter at wimba.com
Mon Jun 23 13:15:18 EST 2003


I'm trying to write a decorator class for the Perl LWP::UserAgent class. 
Design Patterns defines a decorator class as (roughly) a class that looks 
like and uses another class but changes its functionality a little. In my 
case, I want a class like LWP::UserAgent but that follows HTTP redirects. 
To do this, I write a class that contains an LWP::UserAgent whose methods 
it calls

However, LWP::UserAgent is quite complex and implements a large number of 
methods, and it would be a pain to type "sub foo { my $self=shift; return 
$self->ua->foo(@_); }" for every single method. Is there some way of 
importing the package and copying all the functions, with my slightly 
modified definitions?

--
   She's probably not.
     - former U.S. Secretary of State Madeleine Albright, when asked
       if she would reconsider her stance on the U.S. nuclear
       armament if her hero, Xena Warrior Princess, was anti-nuke.



More information about the Programming mailing list