in reply to Re: Simple OO Question
in thread Simple OO Question

As an expansion: _Print_Me() is expecting an argument (a reference to a hash), which it puts in $self. It then prints the hash element user out of that argument.

In your version of Show_Me, you don't pass it that expected argument. There are two ways to do so in this case: Using standard function notation (_Print_Me($self)) or using object notation, which implies the object itself as the first argument. ($self->_Print_Me())

Replies are listed 'Best First'.
Re^3: Simple OO Question
by dsheroh (Monsignor) on Sep 16, 2010 at 13:21 UTC
    As a further expansion: The difference between _Print_Me($self) and $self->_Print_Me is that _Print_Me($self) will always use the current package's _Print_Me, while $self->_Print_Me will find the appropriate _Print_Me for the package (class) that $self is blessed into.

    As a general rule, you'll want to use _Print_Me($self) when you want to use one specific implementation, no matter what, and use $self->_Print_Me when you want to allow for polymorphism (which should be almost always, since you never know when $self might belong to a subclass which has overridden _Print_Me).