File Coverage

blib/lib/Tie/FileHandle/Buffer.pm
Criterion Covered Total %
statement 6 14 42.8
branch n/a
condition n/a
subroutine 2 6 33.3
pod 0 2 0.0
total 8 22 36.3


line stmt bran cond sub pod time code
1             #!/usr/local/bin/perl
2            
3             =head1 NAME
4            
5             Tie::FileHandle::Buffer - filehandle tie that captures output
6            
7             =head1 DESCRIPTION
8            
9             This module, when tied to a filehandle, will capture and store all that
10             is output to that handle. You may then act on that stored information in
11             one of the following ways.
12            
13             my $contents = (tied *HANDLE)->get_contents; # retrieves the stored output
14            
15             (tied *HANDLE)->clear; # clears the output buffer
16            
17             This module goes hand in hand with the Output::Buffer module.
18            
19             =head1 TODO
20            
21             =over 4
22            
23             =item *
24            
25             test.pl
26            
27             =back
28            
29             =head1 BUGS
30            
31             This is a new module and has not been thoroughly tested.
32            
33             =cut
34            
35             package Tie::FileHandle::Buffer;
36            
37 1     1   6922 use vars qw(@ISA $VERSION);
  1         2  
  1         66  
38 1     1   6 use base qw(Tie::FileHandle::Base);
  1         3  
  1         1077  
39             $VERSION = 0.11;
40            
41             # TIEHANDLE
42             # Usage: tie *HANDLE, 'Tie::FileHandle::Buffer'
43             sub TIEHANDLE {
44 0     0     my $self = '';
45 0           bless \$self, $_[0];;
46             }
47            
48             # Print to the selected handle
49             sub PRINT {
50 0     0     ${$_[0]} .= $_[1];
  0            
51             }
52            
53             # Retrieve the contents
54             sub get_contents {
55 0     0 0   ${$_[0]};
  0            
56             }
57            
58             # Discard the contents
59             sub clear {
60 0     0 0   ${$_[0]} = '';
  0            
61             }
62            
63             1;
64            
65             =head1 AUTHORS AND COPYRIGHT
66            
67             Written by Robby Walker ( robwalker@cpan.org ) for Point Writer ( http://www.pointwriter.com/ ).
68            
69             You may redistribute/modify/etc. this module under the same terms as Perl itself.
70