in reply to why "Bless" in OO Perl

bless attaches a class name to a reference. When I call a method on the reference, Perl looks in that class to find the method.

The return value is just the reference, now with the class label attached to it. See the bless entry in perlfunc for the details.

--
brian d foy <brian@stonehenge.com>
Subscribe to The Perl Review

Replies are listed 'Best First'.
Re^2: why "Bless" in OO Perl
by Zaxo (Archbishop) on May 03, 2006 at 16:21 UTC

    The class name is really attached to the object of the reference. That is just rarely seen because the object is usually scoped to the constructor's code block, so it doesn't get observed in the wild. Example code shows this in my reply below.

    After Compline,
    Zaxo