File Coverage

blib/lib/Term/ReadLine/Tiny/readline.pm
Criterion Covered Total %
statement 16 22 72.7
branch n/a
condition n/a
subroutine 5 7 71.4
pod 1 2 50.0
total 22 31 70.9


line stmt bran cond sub pod time code
1             package Term::ReadLine::Tiny::readline;
2             =head1 NAME
3              
4             Term::ReadLine::Tiny::readline - A non-OO package of Term::ReadLine::Tiny
5              
6             =head1 VERSION
7              
8             version 1.07
9              
10             =head1 SYNOPSIS
11              
12             use Term::ReadLine::Tiny::readline;
13            
14             while ( defined($_ = readline("Prompt: ")) )
15             {
16             print "$_\n";
17             }
18             print "\n";
19            
20             $s = "";
21             while ( defined($_ = readkey(1)) )
22             {
23             $s .= $_;
24             }
25             print "\n$s\n";
26              
27             =cut
28 1     1   2635 use strict;
  1         2  
  1         22  
29 1     1   5 use warnings;
  1         2  
  1         18  
30 1     1   9 use v5.10.1;
  1         3  
31 1     1   4 use Term::ReadLine::Tiny;
  1         2  
  1         96  
32              
33              
34             BEGIN
35             {
36 1     1   8 require Exporter;
37 1         3 our $VERSION = '1.07';
38 1         17 our @ISA = qw(Exporter);
39 1         9 our @EXPORT = qw(readline readkey);
40 1         143 our @EXPORT_OK = qw();
41             }
42              
43              
44             =head1 Functions
45              
46             =cut
47             =head2 readline([$prompt[, $default[, IN[, OUT]]]])
48              
49             interactively gets an input line. Trailing newline is removed.
50              
51             Returns C on C.
52              
53             =cut
54             sub readline
55             {
56 0     0 0   my ($prompt, $default, $IN, $OUT) = @_;
57 0           my $term = Term::ReadLine::Tiny->new(undef, $IN, $OUT);
58 0           return $term->readline($prompt, $default);
59             }
60              
61             =head2 readkey([$echo[, IN[, OUT]]])
62              
63             reads a key from input and echoes if I argument is C.
64              
65             Returns C on C.
66              
67             =cut
68             sub readkey
69             {
70 0     0 1   my ($echo, $IN, $OUT) = @_;
71 0           my $term = Term::ReadLine::Tiny->new(undef, $IN, $OUT);
72 0           return $term->readkey($echo);
73             }
74              
75              
76             1;
77             __END__