--- name: bless status: documented runtime: pp source: src/runtime/pp/array_ops.rs --- ```{index} single: bless; Perl built-in (pp runtime) ``` # bless ## Synopsis ```perl my $obj = bless {}, 'MyClass'; my $obj = bless {}; # blesses into current package my $obj = bless \$scalar, 'Foo'; my $obj = bless [], 'Bar'; ``` ## Description Associates a reference with a package, turning it into an object. Marks the referent so that method calls will dispatch through the given class (or the current package if no class is specified). The reference is modified in place and also returned, enabling the common `return bless {}, $class` pattern. Handles multiple referent types: for `Av` and `Hv` containers the blessing is stored via interior mutability on the container itself. For `Rv` wrapping an `Av` or `Hv`, the inner container is blessed. For scalar references, a new blessed `RvInner` is created. ## See also ref, Scalar::Util