File Coverage

blib/lib/Pod/Simple/TiedOutFH.pm
Criterion Covered Total %
statement 27 36 75.0
branch 5 8 62.5
condition 4 9 44.4
subroutine 7 11 63.6
pod 0 1 0.0
total 43 65 66.1


line stmt bran cond sub pod time code
1              
2 68     68   6751 use strict;
  68         145  
  68         3101  
3             package Pod::Simple::TiedOutFH;
4 68     68   30513 use Symbol ('gensym');
  68         45224  
  68         5062  
5 68     68   455 use Carp ();
  68         149  
  68         1242  
6 68     68   312 use vars qw($VERSION );
  68         125  
  68         19647  
7             $VERSION = '3.43';
8              
9             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10              
11             sub handle_on { # some horrible frightening things are encapsulated in here
12 870     870 0 1698 my $class = shift;
13 870   33     3046 $class = ref($class) || $class;
14            
15 870 50       1953 Carp::croak "Usage: ${class}->handle_on(\$somescalar)" unless @_;
16            
17 870 100 66     2963 my $x = (defined($_[0]) and ref($_[0]))
18             ? $_[0]
19             : ( \( $_[0] ) )[0]
20             ;
21 870 50       1772 $$x = '' unless defined $$x;
22            
23             #Pod::Simple::DEBUG and print STDERR "New $class handle on $x = \"$$x\"\n";
24            
25 870         2793 my $new = gensym();
26 870         16496 tie *$new, $class, $x;
27 870         2327 return $new;
28             }
29              
30             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
31              
32             sub TIEHANDLE { # Ties to just a scalar ref
33 870     870   2197 my($class, $scalar_ref) = @_;
34 870 50       2069 $$scalar_ref = '' unless defined $$scalar_ref;
35 870   33     3892 return bless \$scalar_ref, ref($class) || $class;
36             }
37              
38             sub PRINT {
39 18141     18141   26741 my $it = shift;
40 18141         28794 foreach my $x (@_) { $$$it .= $x }
  39096         67229  
41              
42             #Pod::Simple::DEBUG > 10 and print STDERR " appended to $$it = \"$$$it\"\n";
43              
44 18141         34755 return 1;
45             }
46              
47             sub FETCH {
48 0     0     return ${$_[0]};
  0            
49             }
50              
51             sub PRINTF {
52 0     0     my $it = shift;
53 0           my $format = shift;
54 0           $$$it .= sprintf $format, @_;
55 0           return 1;
56             }
57              
58 0     0     sub FILENO { ${ $_[0] } + 100 } # just to produce SOME number
  0            
59              
60 0     0     sub CLOSE { 1 }
61              
62             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63             1;
64             __END__