Reference: bless (Perl in a Nutshell)

Perl in a Nutshell

Perl in a NutshellSearch this book
Previous: Reference: binmodeChapter 5
Function Reference
Next: Reference: caller
 

bless

bless $ref, [classname]

Looks up the item pointed to by reference ref and tells the item that it is now an object in the classname package - or the current package if no classname is specified. It returns the reference for convenience, since a bless is often the last thing in a constructor function. (Always use the two-argument version if the constructor doing the blessing might be inherited by a derived class. In such cases, the class you want to bless your object into will normally be found as the first argument to the constructor in question.)


Previous: Reference: binmodePerl in a NutshellNext: Reference: caller
Reference: binmodeBook IndexReference: caller

Library Navigation Links

Copyright © 2001 O'Reilly & Associates. All rights reserved.