diff options
-rw-r--r-- | lib/App/Raps2/UI.pm | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/App/Raps2/UI.pm b/lib/App/Raps2/UI.pm index 9d6b458..0b8f5fd 100644 --- a/lib/App/Raps2/UI.pm +++ b/lib/App/Raps2/UI.pm @@ -15,8 +15,6 @@ sub new { my $ref = {}; - $ref->{term_readline} = Term::ReadLine->new('App::Raps2'); - return bless( $ref, $obj ); } @@ -37,6 +35,12 @@ sub list { sub read_line { my ( $self, $str, $pre ) = @_; + # Term::ReadLine->new() takes quite long but is not always required. + # So create it here (if needed) instead of in ->new + if ( not $self->{term_readline} ) { + $self->{term_readline} = Term::ReadLine->new('App::Raps2'); + } + my $input = $self->{term_readline}->readline( "${str}: ", $pre ); return $input; |