1: #!/usr/bin/perl
2: package chgkfiles;
3: use DBI;
4: use Exporter;
5: use vars qw(@ISA @EXPORT);
6: @ISA=qw(Exporter);
7:
8: @EXPORT = qw(&input_files &output_files &mywrite &auto_message
9: &myprint &config_error &getstring);
10:
11:
12: BEGIN {do "chgk.cnf"};
13:
14: my %prt;
15:
16: sub auto_message
17: {
18: my $time=localtime;
19: my $f=$_[0];
20:
21: print $f "# This file is automatically generated at $time by $_[1]\n";
22: }
23:
24: sub mywrite
25: {
26: (my $file, %prt)=@_;
27: write $file;
28: }
29:
30: sub myprint
31: {
32: (my $file, @prt)=@_;
33: print $file @prt;
34: }
35:
36: sub setcount
37: {
38: $c=shift
39: }
40:
41: sub setword
42: {
43: $word=shift
44: }
45:
46:
47: sub getstring #берёт первую
48: {
49:
50: if ($#_>=1) { $a=$_[1]; $pattern=qr/$_[0]/}
51: else {$a=$_[0]; $pattern=qr/\s+/};
52: do
53: {
54: $b=<$a>;
55: $b =~ s/^\s+//g;
56: $b =~ s/\s+$//g;
57: $b =~ s/\#.*$//g;
58: }
59: until (($b ne '')||eof($a));
60:
61:
62: $b ? split(/$pattern/, $b):undef;
63: }
64:
65: sub config_error()
66: {
67: "Can not open $_[0] file ${$_[0]}. Check your config.pl";
68: }
69:
70:
71:
72: sub input_files
73: {
74: foreach $file (@_)
75: {
76: my $f=lc $file;
77: open($file, "<$$f") or die "Can not open $file file $$f. Check your chgk.cnf\n";
78: }
79: }
80:
81: sub output_files
82: {
83: foreach $file (@_)
84: {
85: my $f=lc $file;
86: open($file, ">$$f") or die "Can not open $file file $$f. Check your chgk.cnf\n";
87: }
88: }
89:
90: format WORDLIST =
91: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
92: $prt{c}, $prt{word}
93: .
94:
95:
96: format DWORDLIST =
97: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
98: $prt{c}, $prt{word}
99: .
100:
101: format VWORDLIST =
102: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
103: $prt{c}, $prt{word}
104: .
105:
106:
107: format EWORDLIST =
108: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
109: $prt{c}, $prt{word}
110: .
111:
112: format KWORDLIST =
113: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
114: $prt{c}, $prt{word}
115: .
116:
117:
118:
119: format TABLE =
120: @<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
121: $prt{word}, $prt{nf}, $prt{flag}
122: .
123:
124: format NEWTABLE =
125: @<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
126: $prt{word}, $prt{nf}
127: .
128:
129:
130:
131: format NF =
132: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
133: $prt{c}, $prt{word}, $prt{flag}
134: .
135:
136: format NEWNF =
137: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
138: $prt{c}, $prt{word}
139: .
140:
141:
142: format ERRORS =
143: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
144: $prt{c}, $prt{word}
145: .
146:
147: format NEWERRORS =
148: @####### @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
149: $prt{c}, $prt{word}
150: .
151:
152: format VERSIONS =
153: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
154: $prt{c}, $prt{word}, $prt{k}
155: .
156:
157: format EQUALS =
158: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
159: $prt{first}, $prt{second}
160: .
161:
162: format IN2OUT =
163: @<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
164: $prt{in}, $prt{out}
165: .
166:
167: format CTABLE =
168: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
169: $prt{word}, $prt{number}
170: .
171:
172: format CNF =
173: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
174: $prt{kvo}
175: .
176:
177: format ALIKE =
178: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
179: $prt{first}, $prt{second}
180: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
181: $prt{first}, $prt{second}
182: .
183:
184:
185: 1;
186:
187: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>