in reply to Re: Blessing tied hash
in thread Blessing tied hash
Though bless indeed requires a reference as argument it actually tells the thingy referenced by REF that it is now an object, so it blesses the thingy, and not the reference:
use 5.010; use strict; use warnings; my %hash; say ref \%hash; bless \%hash, "Whatever"; say ref \%hash; __END__ HASH Whatever
PS of course you can bless reference too:
use 5.010; use strict; use warnings; my %hash; my $ref = \%hash; bless $ref, 'Array'; bless \$ref, 'Whatever'; say ref \%hash; say ref \$ref; __END__ Array Whatever
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Blessing tied hash
by anazawa (Scribe) on May 06, 2012 at 07:24 UTC | |
by zwon (Abbot) on May 06, 2012 at 10:34 UTC | |
by anazawa (Scribe) on May 06, 2012 at 13:29 UTC |
In Section
Seekers of Perl Wisdom