summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2011-08-30 00:50:37 +0200
committerDaniel Friesel <derf@finalrewind.org>2011-08-30 00:50:37 +0200
commita9358cc0e672b4ea3b63352d5cff2bc1bd42b80d (patch)
tree5ac61e1bc6bf4b7862d9a9ee34135f75af588bda
parent4e5249063822bb91adabe6412a161752872c50c5 (diff)
Raps2/UI.pm: Only create Term::ReadLine object when neccessary
-rw-r--r--lib/App/Raps2/UI.pm8
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;