marathon.pl untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 9 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 56 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/bin/perl -Ilib
2  
3 =head2 marathon.pl
4  
5 Example usage of the Acme::KeyboardMarathon module. Just give it filename(s) on
6 the command line as arguments and it returns the total distance.
7  
8 $> ./marathon.pl foo.txt bar.txt baz.txt
9  
10 The first argument may be --qwerty or --dvorak, to specify the keyboard
11 layout. It defaults to QWERTY.
12  
13 =cut
14  
15 use Acme::KeyboardMarathon;
16 use Math::BigInt lib => 'GMP';
17 use strict;
18 use warnings;
19  
20 my $akm = new Acme::KeyboardMarathon
21 layout => $ARGV[0] =~ /^--\w/ ? substr shift(@ARGV), 2 : 'qwerty';
22  
23 our @ARGV;
24 my $total = Math::BigInt->bzero();
25  
26 for my $file ( @ARGV ) {
27 print STDERR "Skipping [$file] as it is not a file\n" and next unless -f $file;
28 print STDERR "Skipping [$file] as it is a binary file\n" and next if $file =~ /\.(gif|gz|jpe?g|png|tar)$/o or -B $file;
29 print STDERR "Skipping [$file] as it is likely a git binary file\n" and next if $file =~ /\.git\//;
30 print STDERR "Reading [$file]\n";
31 open INFILE, '<', $file;
32 while ( my $line = <INFILE> ) {
33 $total += $akm->distance($line);
34 }
35 close INFILE;
36 }
37  
38 if ( $total > 100000 ) {
39 $total /= 100000;
40 print sprintf('%0.2f',$total) . " km\n";
41 } elsif ( $total > 100 ) {
42 $total /= 100;
43 print sprintf('%0.2f',$total) . " m\n";
44 } else {
45 print $total . " cm\n";
46 }