use strict; use warnings; require Data::Dumper; my $foo = { # blessed one => 1, two => 2, six => 6, }; bless $foo, q{Number::3ch}; my $bar = { # not blessed one => 1, two => 2, six => 6, }; sub foo { # pass by ref my $ref = shift; $ref->{one} = q{One}; $ref = {}; # why won't this replace the underlying hash? return $ref; } # try on blessed reference print Data::Dumper::Dumper($foo); foo $foo; print Data::Dumper::Dumper($foo); # try on unblessed reference print Data::Dumper::Dumper($bar); foo $bar; print Data::Dumper::Dumper($bar); #### $VAR1 = bless( { 'six' => 6, 'two' => 2, 'one' => 1 }, 'Number::3ch' ); $VAR1 = bless( { 'six' => 6, 'two' => 2, 'one' => 'One' }, 'Number::3ch' ); $VAR1 = { 'six' => 6, 'one' => 1, 'two' => 2 }; $VAR1 = { 'six' => 6, 'one' => 'One', 'two' => 2 };