in reply to Help understanding perltooc examples?

(It actually has 7 slots, but that's not important.)

Yes, it does create those methods. Each of those subroutines is a closure over $datum, so each one knows exactly what $datum it is dealing with.

As for the shift->classobj(), that shift is affecting the @_ that came into the subroutine. So, if you were to say:

my $x = $self->foo();
where foo is some legal datum, what happens it the anonymous sub's @_ is populated with $self. That is shift'ed, then the _classobj() method is called on it and assigned to $self within the anonymous subroutine.

Replies are listed 'Best First'.
Re^2: Help understanding perltooc examples?
by injunjoel (Priest) on Feb 19, 2005 at 22:58 UTC
    Greetings,
    Ahhh! I see now!
    7 slots! wow... but it only populates for the &{$datum} slot so to speak. so $$datum, et al. are still usable.
    Thanks for the explanation on the shift->_classobj() call, it makes total sense now. Its acting on what shift is returning which just so happens to be the object instance doing the calling.
    Thanks again,

    -InjunJoel
    "I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo