line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pipe::Tube::Print; |
2
|
1
|
|
|
1
|
|
15
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
62
|
|
3
|
1
|
|
|
1
|
|
38
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
17
|
use 5.006; |
|
1
|
|
|
|
|
5
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base 'Pipe::Tube'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
337
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub init { |
11
|
4
|
|
|
4
|
0
|
8
|
my ($self, $file) = @_; |
12
|
|
|
|
|
|
|
# file can be either undef -> STDOUT or a filehandle, or a filename -> print into that file, |
13
|
4
|
50
|
|
|
|
9
|
if ($file) { |
14
|
4
|
100
|
|
|
|
13
|
if (not ref $file) { # string, assume filename |
|
|
50
|
|
|
|
|
|
15
|
2
|
50
|
|
|
|
171
|
open my $fh, ">", $file or die $!; |
16
|
2
|
|
|
|
|
8
|
$self->{fh} = $fh; |
17
|
2
|
|
|
|
|
17
|
$self->logger("Print: received filename"); |
18
|
|
|
|
|
|
|
} elsif ('GLOB' eq ref $file) { # filehandle |
19
|
2
|
|
|
|
|
4
|
$self->{fh} = $file; |
20
|
2
|
|
|
|
|
5
|
$self->logger("Print: received filehandle"); |
21
|
|
|
|
|
|
|
} else { |
22
|
0
|
|
|
|
|
0
|
die "Unkown type of paramter for print: '" . ref($file) . "'\n"; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
4
|
|
|
|
|
12
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub run { |
29
|
28
|
|
|
28
|
0
|
44
|
my ($self, @input) = @_; |
30
|
28
|
|
|
|
|
95
|
$self->logger("Print: @input"); |
31
|
28
|
50
|
|
|
|
63
|
if (my $fh = $self->{fh}) { |
32
|
28
|
|
|
|
|
114
|
print $fh @input; |
33
|
|
|
|
|
|
|
} else { |
34
|
0
|
|
|
|
|
0
|
print @input; |
35
|
|
|
|
|
|
|
} |
36
|
28
|
|
|
|
|
72
|
return; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|