line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IO::Digest; |
2
|
2
|
|
|
2
|
|
58466
|
use 5.008; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
94
|
|
3
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
543
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
17
|
|
|
2
|
|
|
|
|
81
|
|
5
|
2
|
|
|
2
|
|
5580
|
use PerlIO::via::dynamic '0.10'; |
|
2
|
|
|
|
|
53943
|
|
|
2
|
|
|
|
|
100
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
IO::Digest - Calculate digests while reading or writing |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use IO::Digest; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Get a Digest::MD5 object that takes input while $fh being written or read |
17
|
|
|
|
|
|
|
my $fh; |
18
|
|
|
|
|
|
|
my $iod = IO::Digest->new ($fh, 'MD5'); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
print $fh "fooo"; |
21
|
|
|
|
|
|
|
print $iod->hexdigest |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This module allows you to calculate digests while reading or writing |
26
|
|
|
|
|
|
|
file handles. This avoids the case you need to reread the same |
27
|
|
|
|
|
|
|
content to compute the digests after written a file. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
2
|
|
6229
|
use Digest (); |
|
2
|
|
|
|
|
1590
|
|
|
2
|
|
|
|
|
274
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub new { |
34
|
2
|
|
|
2
|
0
|
440
|
my $class = shift; |
35
|
2
|
|
|
|
|
5
|
my $fh = shift; |
36
|
2
|
|
|
|
|
17
|
my $digest = Digest->new (@_); |
37
|
1
|
|
|
2
|
|
35
|
my $add = sub { $digest->add($_[1]) }; |
|
2
|
|
|
|
|
732
|
|
38
|
1
|
|
|
|
|
6
|
my %map = (translate => $add, untranslate => $add); |
39
|
1
|
|
|
|
|
14
|
PerlIO::via::dynamic->new ( use_read => 1, %map )->via ($fh); |
40
|
1
|
|
|
|
|
6823
|
return $digest; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 TEST COVERAGE |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
----------------------------------- ------ ------ ------ ------ ------ ------ |
46
|
|
|
|
|
|
|
File stmt branch cond sub time total |
47
|
|
|
|
|
|
|
----------------------------------- ------ ------ ------ ------ ------ ------ |
48
|
|
|
|
|
|
|
blib/lib/IO/Digest.pm 100.0 n/a n/a 100.0 100.0 100.0 |
49
|
|
|
|
|
|
|
Total 100.0 n/a n/a 100.0 100.0 100.0 |
50
|
|
|
|
|
|
|
----------------------------------- ------ ------ ------ ------ ------ ------ |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 AUTHORS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Chia-liang Kao E<lt>clkao@clkao.orgE<gt> |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 COPYRIGHT |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Copyright 2004 by Chia-liang Kao E<lt>clkao@clkao.orgE<gt>. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
61
|
|
|
|
|
|
|
under the same terms as Perl itself. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
See L<http://www.perl.com/perl/misc/Artistic.html> |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |