in reply to Understanding how to *use* a CPAN module

Hi Brad :-). The reason you can't see into the objects innards is indeed its inheritance from Class::Std. Take a look at this bit from the introduction of the Class::Std POD:

Most programmers who use Perl's object-oriented features construct their objects by blessing a hash. But, in doing so, they undermine the robustness of the OO approach. Hash-based objects are unencapsulated: their entries are open for the world to access and modify.

So this is a feature of this particular way of doing objects. Not one I personally particularly care for (which is one of the reasons I said the usage of Class::Std-based modules is not necessarily recommended in my email), but in this case seems to be a resounding success if you are in the habit of peeking into the object in order to figure out how best to use it. The innards of an object should never matter to you as a module user, you should always access them via the published interface, i.e. the methods documented in the module POD. "Normal" (hash-based) Perl modules just trust you to do that and don't prevent you from bypassing the interface. Class::Std and its ilk protect you from yourself in that they only allow access via the interface and don't allow you to peek and prod.

So the answer to your question on how to use a CPAN module: read the module documentation and use the module according to that. If something doesn't work, then break out Data::Dumper and maybe try to figure out why, or send a bug report to the module author that they either fix their module or the docs.


All dogma is stupid.

Replies are listed 'Best First'.
Re^2: Understanding how to *use* a CPAN module
by bradcathey (Prior) on Apr 22, 2008 at 13:27 UTC

    I did read what you had quoted from the docs and got some inkling of what was going on, so thanks for expanding the explanation. If you see my reply to perrin below, you will see I ran into a bug (me thinks) that was throwing me off.

    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot