Re: extending Mail::Box with the manager?
Mark Overmeer <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.mail-box |
|---|---|
| Organization | MARKOV Solutions |
| Message-ID | <[email protected]> |
* Anthony D. Urso ([email protected]) [040107 18:18]: > On Wed, Jan 07, 2004 at 05:25:35PM +0100, Mark Overmeer wrote: > For instance, say I wanted to add this method to Mail::Message: > > sub recent { shift->head->recvstamp > (time - 3600) } Ways to do that in Perl5: 1) In your own code: package Mail::Message; sub recent() { ... } package main; ... 2) In your own code: sub Mail::Message::recent() {...}; 3) send me a patch which is good enough. Don't forget the docs. Perl6 probably has traits for that. See the long discussions on the Perl6 list on the moment. 4) Create a wrapper object (that's what you do in real OO languages) package Wrapper; sub new($) { my ($self, $msg) = @_; bless {msg=>$msg}, $class } sub message() { shift->{msg} } sub recent() { shift->message->head->recvstamp > (time - 3600) } For the brave (something like): sub AUTOLOAD() { shift->message->$AUTOLOAD(@_) } -- MarkOv ------------------------------------------------------------------------ drs Mark A.C.J. Overmeer MARKOV Solutions [email protected] [email protected] http://Mark.Overmeer.net http://solutions.overmeer.net