sub DESTROY { my $self = shift ; if ( $self->{out} && $self->{out}->opened() ) { ... do stuff .... close $self->{out} ; } } #### (in cleanup) Can't locate object method "opened" via package "IO::Handle" at modules/MyTH.pm line 29.