File: support.pm

package info (click to toggle)
webrt 1.0.1-4
  • links: PTS
  • area: contrib
  • in suites: potato
  • size: 652 kB
  • ctags: 324
  • sloc: perl: 5,541; makefile: 265; ansic: 28
file content (86 lines) | stat: -rwxr-xr-x 1,395 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package rt::ui::cli;

sub question_string{
    local ($question,$default)=@_;
    local ($response);
    if ($default) {
	print "$question \[$default\]:";
    }
    else {
	print "$question:";
    }
  $response=&input_string($default);
    return($response);
}
sub question_yes_no{
    local ($question,$default)=@_;
    local ($response);
    if ($default) {    
	if ($default eq "1") {
	    $default='Y';
	}
	else {
	    $default='N';
	}
	
	print "$question \[$default\]:";
    }
    else {
	print "$question [N]:";
    }    $response=&input_yes_no($default);
    return($response);
}
sub question_int{
    local ($question,$default)=@_;
    local ($response);
    if ($default) {
	print "$question \[$default\]:";
    }
    else {
	print "$question:";
    }    $response=&input_int($default);
    return($response);
}


sub input_yes_no {
    local ($default) =@_;
    local ($input);
    chop($input=<STDIN>);
    if (!$input) {
	$input=$default;
    }
    if ($input =~ /^(y|Y|1|t)/) {
	return(1);
    }
    else {
	return(0);
    }
}

sub input_string {
    local ($default) =@_;
    local ($input);
 
    chop($input=<STDIN>);
 
    if (!$input) {
	$input=$default;
 
    }
    return($input);
}

sub input_int {
    local ($default) =@_;
    local ($input);
    
    chop($input=<STDIN>);
    $input=int($input);
    if (!$input) {
	$input=int($default);
    }
    return($input);
}

1;