sub new { my $class = shift; my ( $name ) = @_; my $self = bless { name => $name, handle_in => \*STDIN, handle_out => \*STDOUT, }, $class; ... } sub __print_readline { my ( $self, ... ) = @_; ... print { $self->{handle_out} } $string; ... }