| 1 | package File::Print::Many; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 3 | require Tie::Handle; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | File::Print::Many - Print to more than one file descriptor at once | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 VERSION | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | Version 0.01 | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =cut | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 3 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||
| 20 | 3 | our @ISA = ('Tie::Handle'); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | Print to more than one file descriptor at once. | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =head1 SUBROUTINES/METHODS | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =head2 new | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | my $many = File::Print::Many(fds => [$fout1, $fout2]); | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | =cut | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | sub new { | ||||||||||||||||||||||||||||
| 35 | 8 | ▶ | my $proto = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=8 SCAR=21.2
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | 8 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 8 | ▶ | return unless(defined($class)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 8 | my %params; | |||||||||||||||||||||||||||
| 41 | 8 | ▶ | if(ref($_[0]) eq 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 42 | 3 | %params = %{$_[0]}; | |||||||||||||||||||||||||||
| 43 | } elsif(ref($_[0]) eq 'ARRAY') { | ||||||||||||||||||||||||||||
| 44 | 1 | $params{'fds'} = shift; | |||||||||||||||||||||||||||
| 45 | # } elsif(ref($_[0])) { | ||||||||||||||||||||||||||||
| 46 | # Carp::croak('Usage: new(fds => \@array)'); | ||||||||||||||||||||||||||||
| 47 | } elsif(scalar(@_) % 2 == 0) { | ||||||||||||||||||||||||||||
| 48 | 4 | %params = @_; | |||||||||||||||||||||||||||
| 49 | } else { | ||||||||||||||||||||||||||||
| 50 | 0 | Carp::croak('Usage: new(fds => \@array)'); | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 8 | ▶ | if((ref($params{fds}) ne 'ARRAY') || | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $params{"fds"} ne "ARRAY" or not defined @{$params{"fds"};}[0]
MC/DC100%2/2
ref $params{"fds"} ne "ARRAY" or not defined @{$params{"fds"};}[0]
ref $params{"fds"} ne "ARRAY"
not defined @{$params{"fds"};}[0]
Truth table100%3/3
A or not(B)
A= ref $params{"fds"} ne "ARRAY"B= not defined @{$params{"fds"};}[0]
| |||||||||||||||||||||||||||||
| 54 | 4 | !defined(@{$params{fds}}[0])) { | |||||||||||||||||||||||||||
| 55 | 5 | Carp::croak('Usage: new(fds => \@array)'); | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | return bless { | ||||||||||||||||||||||||||||
| 59 | 3 | _fds => $params{'fds'} | |||||||||||||||||||||||||||
| 60 | }, $class; | ||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =head2 print | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | Send output. | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | $many->print("hello, world!\n"); | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =cut | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | # sub PRINT { | ||||||||||||||||||||||||||||
| 72 | # my $self = shift; | ||||||||||||||||||||||||||||
| 73 | # | ||||||||||||||||||||||||||||
| 74 | # foreach my $fd(@{$self->{'_fds'}}) { | ||||||||||||||||||||||||||||
| 75 | # print $fd @_; | ||||||||||||||||||||||||||||
| 76 | # } | ||||||||||||||||||||||||||||
| 77 | # } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | # sub TIEHANDLE { | ||||||||||||||||||||||||||||
| 80 | # bless \"$_[0]",$_[0]; | ||||||||||||||||||||||||||||
| 81 | # } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | sub print { | ||||||||||||||||||||||||||||
| 84 | 3 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
print: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 85 | 3 | my @data = @_; | |||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 3 | foreach my $fd(@{$self->{'_fds'}}) { | |||||||||||||||||||||||||||
| 88 | 6 | print $fd @data; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | Nigel Horne, C<< <njh at bandsman.co.uk> >> | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =head1 BUGS | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | Please report any bugs or feature requests to C<bug-file-print-many at rt.cpan.org>, | ||||||||||||||||||||||||||||
| 99 | or through the web interface at | ||||||||||||||||||||||||||||
| 100 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Print-Many>. | ||||||||||||||||||||||||||||
| 101 | I will be notified, and then you'll | ||||||||||||||||||||||||||||
| 102 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | L<HTTP::BrowserDetect> | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | perldoc File::Print::Many | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | You can also look for information at: | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | =over 4 | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | =item * RT: CPAN's request tracker | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=File-Print-Many> | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | L<http://annocpan.org/dist/File-Print-Many> | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | L<http://cpanratings.perl.org/d/File-Print-Many> | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | =item * Search CPAN | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | L<http://search.cpan.org/dist/File-Print-Many/> | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | =back | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | Copyright 2018 Nigel Horne. | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | This program is released under the following licence: GPL | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | =cut | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 3 | 1; | |||||||||||||||||||||||||||