| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package File::Cat; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1047
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
39
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
246
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); |
|
|
1
|
|
|
|
|
5
|
|
|
|
1
|
|
|
|
|
442
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
|
10
|
|
|
|
|
|
|
@EXPORT = qw( &cat &cattail ); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$VERSION = '1.2'; |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
File::Cat - Perl implementation of cat(1) |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use File::Cat; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
cat ('/etc/motd', \*STDOUT) |
|
25
|
|
|
|
|
|
|
or die "Can't cat /etc/motd: $!"; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
File::Cat is a module of adventure, danger, and low cunning. With it, you |
|
30
|
|
|
|
|
|
|
will explore some of the most inane programs ever seen by mortals. No |
|
31
|
|
|
|
|
|
|
computer should be without one! |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=over |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=item * |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
cat I, I |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Copies data from EXPR to FILEHANDLE, or returns false if an error occurred. |
|
42
|
|
|
|
|
|
|
EXPR can be either an open readable filehandle or a filename to use as input. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub cat ($$) { |
|
49
|
1
|
|
|
1
|
0
|
332
|
my ($input, $handle) = @_; |
|
50
|
|
|
|
|
|
|
|
|
51
|
1
|
50
|
33
|
|
|
13
|
unless (ref \$input eq 'GLOB' or ref \$input eq 'REF') { |
|
52
|
1
|
50
|
|
|
|
31
|
open FILE, $input or return; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
1
|
|
|
|
|
15
|
while () { |
|
55
|
4
|
|
|
|
|
29
|
print $handle $_; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
1
|
|
|
|
|
11
|
close FILE; |
|
58
|
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
4
|
return (1); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=pod |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=item * |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
cattail I, I |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Prints EXPR to FILEHANDLE -- backwards, line by line -- or returns |
|
71
|
|
|
|
|
|
|
false if an error occurred. Again, EXPR can be either a filehandle |
|
72
|
|
|
|
|
|
|
or a filename. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub cattail ($$) { |
|
79
|
1
|
|
|
1
|
0
|
210
|
my ($input, $handle) = @_; |
|
80
|
1
|
|
|
|
|
5
|
my @lines = (0); |
|
81
|
|
|
|
|
|
|
|
|
82
|
1
|
50
|
33
|
|
|
11
|
unless (ref \$input eq 'GLOB' or ref \$input eq 'REF') { |
|
83
|
1
|
50
|
|
|
|
29
|
open FILE, $input or return; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
1
|
|
|
|
|
15
|
while () { |
|
87
|
4
|
|
|
|
|
20
|
$lines[$.] = tell FILE; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
2
|
pop @lines; |
|
91
|
1
|
|
|
|
|
5
|
while (defined ($_ = pop @lines)) { |
|
92
|
4
|
|
|
|
|
25
|
seek FILE, $_, 0; |
|
93
|
4
|
|
|
|
|
31
|
print $handle scalar(); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
1
|
|
|
|
|
15
|
close FILE; |
|
96
|
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
22
|
return (1); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=pod |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=back |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Dennis Taylor, Ecorbeau@execpc.comE |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 APOLOGIES TO... |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Marc Blank. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
cat(1) |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=cut |