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.

Bless (?), v. t. [imp. & p. p. Blessed (#) or Blest; p. pr. & vb. n. Blessing.] [OE. blessien, bletsen, AS. bletsian, bledsian, bloedsian, fr. bld blood; prob. originally to consecrate by sprinkling with blood. See Blood.]

1.

To make or pronounce holy; to consecrate

And God blessed the seventh day, and sanctified it. Gen. ii. 3.

2.

To make happy, blithesome, or joyous; to confer prosperity or happiness upon; to grant divine favor to.

The quality of mercy is . . . twice blest; It blesseth him that gives and him that takes. Shak.

It hath pleased thee to bless the house of thy servant, that it may continue forever before thee. 1 Chron. xvii. 27 (R. V. )

3.

To express a wish or prayer for the happiness of; to invoke a blessing upon; -- applied to persons.

Bless them which persecute you. Rom. xii. 14.

4.

To invoke or confer beneficial attributes or qualities upon; to invoke or confer a blessing on, -- as on food.

Then he took the five loaves and the two fishes, and looking up to heaven, he blessed them. Luke ix. 16.

5.

To make the sign of the cross upon; to cross (one's self).

[Archaic]

Holinshed.

6.

To guard; to keep; to protect.

[Obs.]

7.

To praise, or glorify; to extol for excellences.

Bless the Lord, O my soul: and all that is within me, bless his holy name. Ps. ciii. 1.

8.

To esteem or account happy; to felicitate.

The nations shall bless themselves in him. Jer. iv. 3.

9.

To wave; to brandish.

[Obs.]

And burning blades about their heads do bless. Spenser.

Round his armed head his trenchant blade he blest. Fairfax.

⇒ This is an old sense of the word, supposed by Johnson, Nares, and others, to have been derived from the old rite of blessing a field by directing the hands to all parts of it. "In drawing [their bow] some fetch such a compass as though they would turn about and bless all the field."

Ascham.

Bless me! Bless us! an exclamation of surprise. Milton. -- To bless from, to secure, defend, or preserve from. "Bless me from marrying a usurer." Shak.

To bless the doors from nightly harm. Milton.

-- To bless with, To be blessed with, to favor or endow with; to be favored or endowed with; as, God blesses us with health; we are blessed with happiness.

 

© Webster 1913.

Log in or registerto write something here or to contact authors.