in reply to Re^2: unexpected behavior on hash passed by reference
in thread unexpected behavior on hash passed by reference
What if I wanted to also remove the blessing?
Sounds like an XY problem and/or that your example isn't really representative - why do you want to do this?
Anyway, TIMTOWTDI:
use warnings; use strict; use Data::Dump; sub one { $_[0] = {abc=>'one'}; } my $r1 = bless {r=>111}, 'One'; dd $r1; # bless({ r => 111 }, "One") one $r1; dd $r1; # { abc => "one" } sub two { my $ref = shift; $$ref = {abc=>'two'}; } my $r2 = bless {r=>222}, 'Two'; dd $r2; # bless({ r => 222 }, "Two") two \$r2; dd $r2; # { abc => "two" } sub three { my $ref = shift; return {abc=>'three'}; } my $r3 = bless {r=>333}, 'Three'; dd $r3; # bless({ r => 333 }, "Three") $r3 = three($r3); dd $r3; # { abc => "three" }
And there's stuff like Acme::Damn, but I'm fairly certain that wouldn't be the right solution.
|
|---|