I got email yesterday asking how to get a misused object to explain what methods it supports. Usually if you do $obj->fgsfds all you get is Can't locate object method "fgsfds" via package "Thing". After a use Help 'Thing' declaration, you get a list of methods supported by $obj, and which class each one is inherited from.
This may not be too useful by itself, but the implementation is very interesting, because it is short (only 30 lines), it requires a large number of less-well-known Perl features, and its use of those features is not too tricky. So studying the implementation of this module is a great way to learn a several advanced features of Perl at once.
I posted the code of the Help.pm module with a detailed explanation of how it works.
In the past, I would have posted it here, but now that I have a blog, I posted it on my blog. But I thought some of you folks would be interested anyway, so I'm announcing it here.
Here it is. Enjoy!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Help.pm automatically explains how to use misused objects
by lodin (Hermit) on Jan 12, 2008 at 08:09 UTC | |
Re: Help.pm automatically explains how to use misused objects
by Jenda (Abbot) on Jan 12, 2008 at 01:21 UTC | |
by Dominus (Parson) on Jan 12, 2008 at 01:29 UTC | |
by pKai (Priest) on Jan 15, 2008 at 10:52 UTC | |
by Jenda (Abbot) on Jan 15, 2008 at 16:04 UTC | |
by pKai (Priest) on Jan 16, 2008 at 12:00 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |
Back to
Meditations