blib/lib/Tie/FileHandle/Buffer.pm

filter: Statementstmt 50.0% 8 / 16 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 2 / 6 Podpod 0.0% 0 / 2 totaltotal 41.6% 10 / 24 CC 1 SCAR 5.1
CC
1
Cov
50%
TIEHANDLE
2.0
PRINT
2.0
get_contents
2.0
CRAP 1.7
↑ Summary
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 ▶use vars qw(@ISA $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
38 1 ▶use base qw(Tie::FileHandle::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
39 1 $VERSION = 0.11;
40
41 # TIEHANDLE
42 # Usage: tie *HANDLE, 'Tie::FileHandle::Buffer'
43 0 ▶sub TIEHANDLE {
Subroutine TIEHANDLE: not called CC=1 SCAR=6.9
44 0 my $self = '';
45 0 bless \$self, $_[0];;
46 }
47
48 # Print to the selected handle
49 0 ▶sub PRINT {
Subroutine PRINT: not called CC=1 SCAR=6.9
50 0 ${$_[0]} .= $_[1];
51 }
52
53 # Retrieve the contents
54 0 ▶sub get_contents {
Subroutine get_contents: not called CC=1 SCAR=6.9
Pod undocumented
55 0 ${$_[0]};
56 }
57
58 # Discard the contents
59 0 ▶sub clear {
Subroutine clear: not called CC=1 SCAR=6.9
Pod undocumented
60 0 ${$_[0]} = '';
61 }
62
63 1 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
↑ Summary