my $term; if ($ENV{TESTING}) { $term = Term::ReadLine->new('My Application', \*STDIN, \*STDOUT); } else { $term = Term::ReadLine->new('My Application'); } #### my $term; if (-t STDIN) { $term = Term::ReadLine->new('My Application'); } else { $term = Term::ReadLine->new('My Application', \*STDIN, \*STDOUT); } #### my $term = Term::ReadLine->new('My Application', \*STDIN, \*STDOUT); #### use IO::Handle; { package IO::Handle; no warnings 'redefine'; sub readline { my ($self) = @_; my $line = $self->getline(); return unless defined $line; chomp($line); return $line; } } my $term; if (-t STDIN) { $term = Term::ReadLine->new('My Application'); } else { $term = *STDIN; }