blib/lib/Term/Getch.pm

filter: Statementstmt 60.0% 6 / 10 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod n/a totaltotal 64.2% 9 / 14 CC 1 SCAR 2.8
CC
1
Cov
60%
ascii
2.0
BEGIN
1.3
BEGIN
1.0
CRAP 1.3
↑ Summary
1 #!/usr/bin/perl
2
3 # Copyright (c) 2000 Josiah Bryan USA
4 #
5 # See AUTHOR section in pod text below for usage and distribution rights.
6 #
7
8 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 $Term::Getch::VERSION = "0.20";
10 1 $Term::Getch::ID =
11 '$Id: Term::Getch.pm, v'.$Term::Getch::VERSION.' 2000/15/09 21:58:25 josiah Exp $';
12 }
13
14
15 package Term::Getch;
16
17 require Exporter;
18
19 @ISA = qw(Exporter);
20 @EXPORT = qw(getch);
21 @EXPORT_OK = qw(ascii);
22
23 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
24
25 my %__ascii__lookup__table;
26 for my $code (0..255){$__ascii__lookup__table{chr($code)}=$code}
27 0 ▶ sub ascii {my $c=shift;$__ascii__lookup__table{$c}}
Subroutine ascii: not called CC=1 SCAR=6.9
28
29 my ($STOUT,$STDERR,$STDIN);
30
31 if($^O eq "MSWin32") {
32 0 ▶ use Win32::Console;
Subroutine BEGIN: called CC=1 SCAR=2.6
33 $STDIN = new Win32::Console(STD_INPUT_HANDLE);
34 } else {
35 eval('use Term::ReadKey');
36 }
37
38
39 sub getch {
40 if($^O eq "MSWin32") {
41 my $e = $STDIN->GetEvents();
42 if($e) {
43 my @in = $STDIN->Input();
44 return chr($in[5]) if($in[0]==1 && !$in[1]);
45 }
46 return undef;
47 } else {
48 return ReadKey();
49 }
50 }
51
52
53
54
55 1;
56 __END__
↑ Summary