File Coverage

blib/lib/App/Timer.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 14 14 100.0


line stmt bran cond sub pod time code
1             package App::Timer;
2              
3             $App::Timer::VERSION = '0.01';
4             $App::Timer::AUTHORITY = 'cpan:MANWAR';
5              
6 1     1   60834 use strict;
  1         2  
  1         28  
7 1     1   4 use warnings;
  1         2  
  1         129  
8              
9             =head1 NAME
10              
11             App::Timer - Timer for your application.
12              
13             =head1 VERSION
14              
15             Version 0.01
16              
17             =head1 DESCRIPTION
18              
19             Every time, I create a command line tool in B, I would just add
20             the following lines at the end of the script.
21              
22             END {
23             my $time = time - $^T;
24             my $mm = $time / 60;
25             my $ss = $time % 60;
26             my $hh = $mm / 60;
27              
28             printf("The program ran for %02d:%02d:%02d.\n", $hh, $mm%60, $ss);
29             }
30              
31             Having done it more than once, I decided to come up with something as
32             smooth as possible. This is my attempt in that direction.
33              
34             I found somewhat similar work done in L. The only issue
35             is that it has dependency on a non-core module L.
36              
37             =head1 SYNOPSIS
38              
39             To get the timer enable for your command line tool, just add the line
40             below at the top of the script and you are good to go.
41              
42             use App::Timer;
43              
44             =cut
45              
46             sub import {
47             END {
48 1     1   679 my $time = time - $^T;
49 1         3 my $mm = $time / 60;
50 1         2 my $ss = $time % 60;
51 1         3 my $hh = $mm / 60;
52              
53 1         68 printf("The program ran for %02d:%02d:%02d.\n", $hh, $mm%60, $ss);
54             }
55             }
56              
57             =head1 AUTHOR
58              
59             Mohammad S Anwar, C<< >>
60              
61             =head1 REPOSITORY
62              
63             L
64              
65             =head1 SEE ALSO
66              
67             L
68              
69             =head1 BUGS
70              
71             Please report any bugs or feature requests to C,
72             or through the web interface at L.
73             I will be notified and then you'll automatically be notified of progress on your
74             bug as I make changes.
75              
76             =head1 SUPPORT
77              
78             You can find documentation for this module with the perldoc command.
79              
80             perldoc App::Timer
81              
82             You can also look for information at:
83              
84             =over 4
85              
86             =item * CPAN Ratings
87              
88             L
89              
90             =item * Search MetaCPAN
91              
92             L
93              
94             =back
95              
96             =head1 LICENSE AND COPYRIGHT
97              
98             Copyright (C) 2022 Mohammad S Anwar.
99              
100             This program is free software; you can redistribute it and / or modify it under
101             the terms of the the Artistic License (2.0). You may obtain a copy of the full
102             license at:
103              
104             L
105              
106             Any use, modification, and distribution of the Standard or Modified Versions is
107             governed by this Artistic License.By using, modifying or distributing the Package,
108             you accept this license. Do not use, modify, or distribute the Package, if you do
109             not accept this license.
110              
111             If your Modified Version has been derived from a Modified Version made by someone
112             other than you,you are nevertheless required to ensure that your Modified Version
113             complies with the requirements of this license.
114              
115             This license does not grant you the right to use any trademark, service mark,
116             tradename, or logo of the Copyright Holder.
117              
118             This license includes the non-exclusive, worldwide, free-of-charge patent license
119             to make, have made, use, offer to sell, sell, import and otherwise transfer the
120             Package with respect to any patent claims licensable by the Copyright Holder that
121             are necessarily infringed by the Package. If you institute patent litigation
122             (including a cross-claim or counterclaim) against any party alleging that the
123             Package constitutes direct or contributory patent infringement,then this Artistic
124             License to you shall terminate on the date that such litigation is filed.
125              
126             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND
127             CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED
128             WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
129             NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS
130             REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT,
131             INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE
132             OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
133              
134             =cut
135              
136             1; # End of App::Timer