# note the package level shared hash; this will store the # actual values of the active attribute. my %active : shared; # CONSTRUCTOR sub new { local *IN; my $self = {}; $self->{active} = \$active{$self} = 1; # This variable must be shared between threads. $self->{in} = undef; $self->{thread} = undef; open(*IN, "a_program" ) or ${$self->{active}} = 0; $self->{in} = *IN; $self->{thread} = threads->new(\&reader, $self); # Start thread bless($self); return $self; }