Perl bless

After saying bless reference [, class], the thingy referred to (by reference) becomes an object in the package class (by default, the current package). This means that a method call on a reference to that thingy will search for the method in package class.

So after

$y = 42;
$x = \$y;
bless $x, 'Foo';
a call of $x->print(11) will be translated to Foo::print($x,11) if Foo::print exists (and if it doesn't, Perl will search for an appropriate method using @Foo::ISA and Foo::AUTOLOAD, as per the usual rules for inheritance).

bless is often the last function called in a constructor (usually the routine Foo::new). As such, it returns its first argument, after blessing.

While typically objects are implemented as hash thingies, as the above example shows any scalar reference can be blessed.