diff options
author | Guilhem Moulin <guilhem.moulin@ens-lyon.org> | 2012-03-01 18:47:04 +0100 |
---|---|---|
committer | Guilhem Moulin <guilhem.moulin@ens-lyon.org> | 2012-03-01 18:47:04 +0100 |
commit | c2d71e2a8243638dea4654e2eff8f2a61e504091 (patch) | |
tree | bf320792f06e917d7cfab73c44df01510daf199f | |
parent | ae4bb8da9e1dd41abf5d564b471c68de7b2acdb8 (diff) |
question
-rwxr-xr-x | videoadd.pl | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/videoadd.pl b/videoadd.pl index bf1a224..a6b0ed3 100755 --- a/videoadd.pl +++ b/videoadd.pl @@ -304,7 +304,9 @@ if ( defined ($imdb{crit}) and &runIMDb() ) { for (my $i=0; $i<72; $i++) {print '=' or die "Can't print: $!"}; print "\n" or die "Can't print: $!"; - $imdb{crit} = &ask ( \@options, "Choose an ID above:", $options[0] ); + $imdb{crit} = &question ( \@options, + "Choose an IMDb ID above, to retrieve data from:", + $options[0] ); } else { $single = 1; @@ -534,7 +536,7 @@ if ( defined ($file) and defined ($move_flag) ) { my $dir = catdir ( $directors, $new{director} ); unless (-d $dir) { print STDERR "Directory `$dir' does not exist. "; - my $answer = &askYN( "Should I create it?", 'y' ); + my $answer = &YNquestion( "Should I create it?", 'y' ); if ($answer eq 'y') { mkdir $dir or die "Error: Cannot mkdir `$dir': $!\n"; } @@ -670,7 +672,7 @@ sub getfile { for (my $i=0; $i<72; $i++) {print '=' or die "Can't print: $!"}; print "\n" or die "Can't print: $!"; - $answer = &ask ( \@options, "Choose an ID above:", $options[0] ); + $answer = &question ( \@options, "Choose an ID above to update:", $options[0] ); } $answer =~ s/^0+//; @@ -751,7 +753,7 @@ sub runMplayer { } # Ask a question interactively -sub ask { +sub question { my ($options, $question, $default, $pdefault) = @_; my $answer; @@ -775,10 +777,12 @@ sub ask { return $answer; } -# Ask a Yes/No question -sub askYN { +# Yes/No question +sub YNquestion { my ($question, $default) = @_; + my $pdefault = "Y/n"; $pdefault = "y/N" if $default eq 'n'; - return &ask ( ['y','n'], $question, $default, $pdefault ); + + return &question ( ['y','n'], $question, $default, $pdefault ); } |