|
|
| Syntactic Confectionery Delight | |
| PerlMonks |
Re: Safer monkey-patchingby dwalin (Monk) |
| on Jan 19, 2012 at 06:30 UTC ( #948697=note: print w/ replies, xml ) | Need Help?? |
|
In my experience, monkey patching usually is not worth its trouble. The problem you describe above I would solve by subclassing + duck typing: in Example::ErrorList, provide a method that returns list item class name, and instantiate objects of that name. This way you can subclass both Example::ErrorList and Example::Error in a "clean" way. Like this:
You also have a typo: my $self = @_; won't work the way you expect.
Regards,
In Section
Meditations
|
|
||||||||||||||||||||||