line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#! /usr/bin/perl -w |
2
|
|
|
|
|
|
|
################################################################################ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# File.pm (do cool things with files) |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
################################################################################ |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Package |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
################################################################################ |
11
|
|
|
|
|
|
|
package PML::File; |
12
|
|
|
|
|
|
|
################################################################################ |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Includes |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
################################################################################ |
17
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
50
|
|
18
|
|
|
|
|
|
|
################################################################################ |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
# Global Variables and Default Settings |
21
|
|
|
|
|
|
|
# |
22
|
|
|
|
|
|
|
################################################################################ |
23
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION $DATE $ID); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
977
|
|
24
|
|
|
|
|
|
|
$VERSION = '0.01'; |
25
|
|
|
|
|
|
|
$DATE = 'Wed May 24 16:58:17 2000'; |
26
|
|
|
|
|
|
|
$ID = '$Id: File.pm,v 1.4 2000/07/31 17:13:46 pjones Exp $'; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $pkg = 'file::'; |
29
|
|
|
|
|
|
|
my $local = "${pkg}local"; |
30
|
|
|
|
|
|
|
my $prefix = "${pkg}prefix"; |
31
|
|
|
|
|
|
|
my $dprefix = 'conf'; |
32
|
|
|
|
|
|
|
################################################################################ |
33
|
|
|
|
|
|
|
# |
34
|
|
|
|
|
|
|
# Code Start |
35
|
|
|
|
|
|
|
# |
36
|
|
|
|
|
|
|
################################################################################ |
37
|
|
|
|
|
|
|
PML->register(name=>"${pkg}cat", token=>\&cat); |
38
|
|
|
|
|
|
|
PML->register(name=>"${pkg}conf",token=>\&conf); |
39
|
|
|
|
|
|
|
################################################################################ |
40
|
|
|
|
|
|
|
# |
41
|
|
|
|
|
|
|
# ==== cat ==== ################################################################ |
42
|
|
|
|
|
|
|
# |
43
|
|
|
|
|
|
|
# Arguments: |
44
|
|
|
|
|
|
|
# See PML Docs |
45
|
|
|
|
|
|
|
# |
46
|
|
|
|
|
|
|
# Returns: |
47
|
|
|
|
|
|
|
# The contents of the files |
48
|
|
|
|
|
|
|
# |
49
|
|
|
|
|
|
|
# Description: |
50
|
|
|
|
|
|
|
# Returns the contents of a bunch of files |
51
|
|
|
|
|
|
|
# |
52
|
|
|
|
|
|
|
################################################################################ |
53
|
|
|
|
|
|
|
sub cat |
54
|
|
|
|
|
|
|
{ |
55
|
1
|
|
|
1
|
0
|
3
|
my ($self, $token) = @_; |
56
|
1
|
|
|
|
|
1
|
my ($name, $a, $b) = @{$token->data}; |
|
1
|
|
|
|
|
6
|
|
57
|
1
|
|
|
|
|
2
|
my (@files, $file, $result); |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
7
|
@files = $self->tokens_execute($a); |
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
3
|
foreach $file (@files) { |
62
|
1
|
50
|
|
|
|
71
|
unless (open CAT, $file) { |
63
|
0
|
0
|
|
|
|
0
|
if ($self->warning) { |
64
|
0
|
|
|
|
|
0
|
print STDERR "can't open file '$file': $!\n"; |
65
|
|
|
|
|
|
|
} |
66
|
0
|
|
|
|
|
0
|
next; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
27
|
$result .= join '', ; |
70
|
1
|
|
|
|
|
11
|
close CAT; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
6
|
return $result; |
74
|
|
|
|
|
|
|
} # <-- End cat --> |
75
|
|
|
|
|
|
|
################################################################################ |
76
|
|
|
|
|
|
|
# |
77
|
|
|
|
|
|
|
# ==== conf ==== ############################################################### |
78
|
|
|
|
|
|
|
# |
79
|
|
|
|
|
|
|
# Arguments: |
80
|
|
|
|
|
|
|
# See PML Docs |
81
|
|
|
|
|
|
|
# |
82
|
|
|
|
|
|
|
# Returns: |
83
|
|
|
|
|
|
|
# Nothing |
84
|
|
|
|
|
|
|
# |
85
|
|
|
|
|
|
|
# Description: |
86
|
|
|
|
|
|
|
# Loads variables from config file |
87
|
|
|
|
|
|
|
# |
88
|
|
|
|
|
|
|
################################################################################ |
89
|
|
|
|
|
|
|
sub conf |
90
|
|
|
|
|
|
|
{ |
91
|
1
|
|
|
1
|
0
|
3
|
my ($self, $token) = @_; |
92
|
1
|
|
|
|
|
3
|
my ($name, $a, $b) = @{$token->data}; |
|
1
|
|
|
|
|
5
|
|
93
|
1
|
|
|
|
|
2
|
my (@files, $file, $key, $value, $lastline); |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
4
|
@files = $self->tokens_execute($a); |
96
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
2
|
foreach $file (@files) { |
98
|
1
|
50
|
|
|
|
30
|
unless (open CONF, $file) { |
99
|
0
|
0
|
|
|
|
0
|
if ($self->warning) { |
100
|
0
|
|
|
|
|
0
|
print STDERR "can't open file '$file': $!\n"; |
101
|
|
|
|
|
|
|
} |
102
|
0
|
|
|
|
|
0
|
next; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
1
|
|
|
|
|
3
|
$lastline = ''; |
106
|
1
|
|
|
|
|
22
|
while () { |
107
|
15
|
100
|
100
|
|
|
334
|
next if /^\s*$/ or /^\s*#/; |
108
|
|
|
|
|
|
|
|
109
|
5
|
100
|
|
|
|
17
|
if (s|\\$||) { |
110
|
2
|
|
|
|
|
3
|
chomp; |
111
|
2
|
|
|
|
|
5
|
$lastline =~ s/\s+$/ /; s/^\s+//; |
|
2
|
|
|
|
|
6
|
|
112
|
2
|
|
|
|
|
3
|
$lastline .= $_; |
113
|
2
|
50
|
|
|
|
11
|
next unless eof CONF; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
3
|
100
|
|
|
|
7
|
if (length $lastline) { |
117
|
1
|
|
|
|
|
5
|
$lastline =~ s/\s+$/ /; s/^\s+//; |
|
1
|
|
|
|
|
4
|
|
118
|
1
|
|
|
|
|
3
|
$_ = $lastline . $_; |
119
|
1
|
|
|
|
|
2
|
$lastline = ''; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
3
|
|
|
|
|
6
|
s/^\s+//; s/\s+$//; chomp; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
5
|
|
123
|
3
|
|
|
|
|
15
|
($key, $value) = split(/\s*=\s*/, $_, 2); |
124
|
|
|
|
|
|
|
|
125
|
3
|
50
|
|
|
|
8
|
unless ($key) { |
126
|
0
|
0
|
|
|
|
0
|
if ($self->warning) { |
127
|
0
|
|
|
|
|
0
|
print STDERR "no config variable on line $. of file '$file'\n"; |
128
|
|
|
|
|
|
|
} |
129
|
0
|
|
|
|
|
0
|
next; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
3
|
50
|
|
|
|
90
|
if ($self->[PML->PML_V]{$local}) { |
|
|
50
|
|
|
|
|
|
133
|
0
|
|
0
|
|
|
0
|
$self->[PML->PML_V]{$key} = $value || ''; |
134
|
|
|
|
|
|
|
} elsif ($self->[PML->PML_V]{$prefix}) { |
135
|
0
|
|
|
|
|
0
|
$self->[PML->PML_V]{$self->[PML->PML_V]{$prefix}}{$key} = $value; |
136
|
|
|
|
|
|
|
} else { |
137
|
3
|
|
|
|
|
33
|
$self->[PML->PML_V]{$dprefix}{$key} = $value; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
1
|
|
|
|
|
13
|
close CONF; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
1
|
|
|
|
|
6
|
return undef; |
145
|
|
|
|
|
|
|
} # <-- End conf --> |
146
|
|
|
|
|
|
|
################################################################################ |
147
|
|
|
|
|
|
|
# END-OF-SCRIPT # |
148
|
|
|
|
|
|
|
################################################################################ |
149
|
|
|
|
|
|
|
=head1 NAME |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
File.pm |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SYNOPSIS |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Quick Usage |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 DESCRIPTION |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
What does it do? |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 OPTIONS |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Long Usage |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 EXAMPLES |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Example usage |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 SEE ALSO |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
perl(1) |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 AUTHOR |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Peter J Jones |
176
|
|
|
|
|
|
|
pjones@cpan.org |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=cut |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
1; |
181
|
|
|
|
|
|
|
__END__ |