in reply to Re^4: Passing self to process as reference
in thread Passing self to process as reference

"New name" never printing has nothing to do with passing by reference ($self is already reference to the object) and everything to do with how threads work. For more information on this topic by a monk with a similar problem, please see Shared variable not changing?.

Just to reinforce the point that the blessed object reference (what is stored in $self) can be used to reset the name when threading doesn't get in the way, consider this example using a closure:

{ package Foo; sub new { my $sClass = shift; my $self= { name => shift }; return bless($self, $sClass); } sub printName { my $self = shift; print $self->{name} . "\n"; }; } my $oFoo = Foo->new(q{George Alan O'Dowd}); my $crPrintCurrentName = sub { $oFoo->printName(); }; &$crPrintCurrentName(); $oFoo->{name} = 'Boy George'; &$crPrintCurrentName();

prints

George Alan O'Dowd Boy George

Best, beth