diff options
author | Daniel Friesel <derf@finalrewind.org> | 2011-08-30 00:50:37 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2011-08-30 00:50:37 +0200 |
commit | a9358cc0e672b4ea3b63352d5cff2bc1bd42b80d (patch) | |
tree | 5ac61e1bc6bf4b7862d9a9ee34135f75af588bda /lib | |
parent | 4e5249063822bb91adabe6412a161752872c50c5 (diff) |
Raps2/UI.pm: Only create Term::ReadLine object when neccessary
Diffstat (limited to 'lib')
-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; |