=over =item bless REF,CLASSNAME X =item bless REF C tells Perl to mark the item referred to by C as an object in a package. The two-argument version of C is always preferable unless there is a specific reason to I use it. =over =item * Bless the referred-to item into a specific package (recommended form): bless $ref, $package; The two-argument form adds the object to the package specified as the second argument. =item * Bless the referred-to item into package C
: bless $ref, ""; If the second argument is an empty string, C adds the object to package C
. =item * Bless the referred-to item into the current package (not inheritable): bless $ref; If C is used without its second argument, the object is created in the current package. The second argument should always be supplied if a derived class might inherit a method executing C. Because it is a potential source of bugs, one-argument C is discouraged. =back See L for more about the blessing (and blessings) of objects. L|/bless REF,CLASSNAME> returns its first argument, the supplied reference, as the value of the function; since C is commonly the last thing executed in constructors, this means that the reference to the object is returned as the constructor's value and allows the caller to immediately use this returned object in method calls. C should always be a mixed-case name, as all-uppercase and all-lowercase names are meant to be used only for Perl builtin types and pragmas, respectively. Avoid creating all-uppercase or all-lowercase package names to prevent confusion. Also avoid ing things into the class name C<0>; this will cause code which (erroneously) checks the result of L|/ref EXPR> to see if a reference is Ced to fail, as "0", a falsy value, is returned. See L for more details. =back