File Coverage

blib/lib/App/adler32.pm
Criterion Covered Total %
statement 27 46 58.7
branch 0 4 0.0
condition n/a
subroutine 9 12 75.0
pod 3 3 100.0
total 39 65 60.0


line stmt bran cond sub pod time code
1 1     1   89031 use strict;
  1         16  
  1         52  
2 1     1   9 use warnings;
  1         3  
  1         82  
3              
4             package App::adler32;
5             # ABSTRACT: Comand-line utility for computing Adler32 digest
6             our $VERSION = '0.001'; # VERSION
7 1     1   9 use base 'App::Cmd::Simple';
  1         3  
  1         423  
8 1     1   40186 use charnames qw();
  1         27631  
  1         29  
9 1     1   436 use open qw( :encoding(UTF-8) :std );
  1         1195  
  1         7  
10 1     1   10948 use Module::Load qw(load);
  1         879  
  1         6  
11 1     1   379 use Getopt::Long::Descriptive;
  1         18675  
  1         8  
12              
13              
14 1     1   374 use utf8;
  1         2  
  1         9  
15 1     1   409 use Digest::Adler32 qw(adler32);
  1         303  
  1         260  
16              
17             =pod
18              
19             =encoding utf8
20              
21             =head1 NAME
22              
23             adler32 - Command-line utility for computing Adler32 digest
24              
25             =head1 VERSION
26              
27             version 0.001
28              
29             =head1 SYNOPSIS
30              
31             $ echo Hey | adler32
32             31014f03
33              
34             =head1 OPTIONS
35              
36             =head2 version / v
37              
38             Shows the current version number
39              
40             $ adler32 --version
41              
42             =head2 help / h
43              
44             Shows a brief help message
45              
46             $ adler32 --help
47              
48             =cut
49              
50             sub opt_spec {
51             return (
52 0     0 1   [ 'version|v' => "show version number" ],
53             [ 'help|h' => "display a usage message" ],
54             );
55             }
56              
57             sub validate_args {
58 0     0 1   my ($self, $opt, $args) = @_;
59              
60 0 0         if ($opt->{'help'}) {
    0          
61 0           my ($opt, $usage) = describe_options(
62             $self->usage_desc(),
63             $self->opt_spec(),
64             );
65 0           print $usage;
66 0           print "\n";
67 0           print "For more detailed help see 'perldoc App::adler32'\n";
68              
69 0           print "\n";
70 0           exit;
71             }
72             elsif ($opt->{'version'}) {
73 0           print $App::adler32::VERSION, "\n";
74 0           exit;
75             }
76              
77 0           return;
78             }
79              
80             sub execute {
81 0     0 1   my ($self, $opt, $args) = @_;
82              
83 0           while (<>) {
84 0           my $a32 = Digest::Adler32->new;
85 0           $a32->add($_);
86 0           my $digest = unpack 'H*', pack 'N', unpack 'L', $a32->digest;
87 0           print $digest, "\n";
88             }
89              
90 0           return;
91             }
92              
93             1;
94              
95             __END__