File Coverage

blib/lib/Term/Info.pm
Criterion Covered Total %
statement 9 10 90.0
branch 1 2 50.0
condition n/a
subroutine 2 2 100.0
pod 0 1 0.0
total 12 15 80.0


line stmt bran cond sub pod time code
1             # Install this in your perl source or installation tree as lib/Term/Info.pm
2              
3             # Call using the following syntax:
4             # $clear = Tput("clear");
5             # print $clear;
6             # print Tput("cup",$row,$col);
7             #
8             # Note that the tput command is required to be in your path somewhere.
9              
10             package Term::Info;
11             require 5.000;
12             require Exporter;
13 1     1   513 use Carp;
  1         1  
  1         258  
14              
15             @ISA = qw(Exporter);
16             @EXPORT = qw(&Tput);
17              
18             %cachetput = ();
19              
20             sub Tput {
21 2     2 0 20 my(@params) = @_;
22 2         10 my($cmd) = "tput";
23 2         20 foreach (@params)
24             {
25 2         20 $cmd .= " \"\Q$_\E\"";
26             }
27 2 50       13 if( defined($cachetput{$cmd}) )
28 0         0 { $cachetput{$cmd} }
29             else
30 2         7325 { $cachetput{$cmd} = `$cmd` }
31             }
32              
33              
34             1;