File Coverage

blib/lib/PerlIO/via/Pod.pm
Criterion Covered Total %
statement 18 18 100.0
branch 14 16 87.5
condition n/a
subroutine 4 4 100.0
pod 0 2 0.0
total 36 40 90.0


line stmt bran cond sub pod time code
1             package PerlIO::via::Pod;
2              
3             $VERSION= '0.06';
4              
5             # be as struct as possible
6 1     1   56735 use strict;
  1         2  
  1         289  
7              
8             # satisfy -require-
9             1;
10              
11             #-------------------------------------------------------------------------------
12             #
13             # Standard Perl features
14             #
15             #-------------------------------------------------------------------------------
16             # IN: 1 class to bless with
17             # 2 mode string (ignored)
18             # 3 file handle of PerlIO layer below (ignored)
19             # OUT: 1 blessed object
20              
21             sub PUSHED {
22              
23             # create the object with the right attributes
24 2     2 0 1085 return bless { inpod => 0 }, $_[0];
25             } #PUSHED
26              
27             #-------------------------------------------------------------------------------
28             # IN: 1 instantiated object
29             # 2 handle to read from
30             # OUT: 1 processed string (if any)
31              
32             sub FILL {
33              
34             # process all lines
35 13     13 0 16 local( $_ );
36 13         35 while ( defined( $_= readline( $_[1] ) )) {
37              
38             # pod, but not the end of it
39 16 100       62 if ( m#^=[a-zA-Z]# ) {
    100          
40 5 100       21 return $_ if $_[0]->{inpod}= !m#^=cut#;
41             }
42              
43             # still in pod
44             elsif ($_[0]->{inpod}) {
45 8         22 return $_;
46             }
47             }
48              
49             # we're done
50 1         15 return undef;
51             } #FILL
52              
53             #-------------------------------------------------------------------------------
54             # IN: 1 instantiated object
55             # 2 buffer to be written
56             # 3 handle to write to
57             # OUT: 1 number of bytes written
58              
59             sub WRITE {
60              
61             # all lines
62 1     1   27 foreach ( split( m#(?<=$/)#, $_[1] ) ) {
63              
64             # not at end of pod
65 16 100       39 if ( m#^=[a-zA-Z]# ) {
    100          
66 5 100       12 if ($_[0]->{inpod} = !m#^=cut#) {
67 4 50       5 return -1 if !print { $_[2] } $_;
  4         10  
68             }
69             }
70              
71             # still in pod
72             elsif ( $_[0]->{inpod} ) {
73 8 50       8 return -1 if !print { $_[2] } $_;
  8         17  
74             }
75             }
76              
77 1         7 return length( $_[1] );
78             } #WRITE
79              
80             #-------------------------------------------------------------------------------
81              
82             __END__