This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
avoid error in IO::Socket::INET when given an unknown service name
[perl5.git] / eg / unuc
CommitLineData
79072805
LW
1#!/usr/bin/perl
2
3print STDERR "Loading proper nouns...\n";
4open(DICT,"/usr/dict/words") || die "Can't find /usr/dict/words: $!\n";
5while (<DICT>) {
6 if (/^[A-Z]/) {
7 chop;
8 ($lower = $_) =~ y/A-Z/a-z/;
9 $proper{$lower} = $_;
10 }
11}
12close DICT;
13print STDERR "Loading exceptions...\n";
14
15$prog = <<'EOT';
16while (<>) {
17 next if /[a-z]/;
18 y/A-Z/a-z/;
19 s/(\w+)/$proper{$1} ? $proper{$1} : $1/eg;
20 s/^(\s*)([a-z])/$1 . (($tmp = $2) =~ y:a-z:A-Z:,$tmp)/e;
21 s/([-.?!]["']?(\n\s*| \s*)["']?)([a-z])/$1 . (($tmp = $3) =~ y:a-z:A-Z:,$tmp)/eg;
22 s/\b([b-df-hj-np-tv-xz]+)\b/(($tmp = $1) =~ y:a-z:A-Z:,$tmp)/eg;
23 s/([a-z])'([SDT])\b/$1 . "'" . (($tmp = $2) =~ y:A-Z:a-z:,$tmp)/eg;
24EOT
25while (<DATA>) {
26 chop;
27 next if /^$/;
28 next if /^#/;
29 if (! /;$/) {
30 $foo = $_;
31 $foo =~ y/A-Z/a-z/;
32 print STDERR "Dup $_\n" if $proper{$foo};
33 $foo =~ s/([^\w ])/\\$1/g;
34 $foo =~ s/ /(\\s+)/g;
35 $foo = "\\b" . $foo if $foo =~ /^\w/; # XXX till patch 9
36 $foo .= "\\b" if $foo =~ /\w$/;
37 $i = 0;
38 ($bar = $_) =~ s/ /'$' . ++$i/eg;
39 $_ = "s/$foo/$bar/gi;";
40 }
41 $prog .= ' ' . $_ . "\n";
42}
43$prog .= "}\ncontinue {\n print;\n}\n";
44
45$/ = '';
46#print $prog;
47eval $prog; die $@ if $@;
48__END__
49A.M.
50Air Force
51Air Force Base
52Air Force Station
53American
54Apr.
55Ariane
56Aug.
57August
58Bureau of Labor Statistics
59CIT
60Caltech
61Cape Canaveral
62Challenger
63China
64Corporation
65Crippen
66Daily News in Brief
67Daniel Quayle
68Dec.
69Discovery
70Edwards
71Endeavour
72Feb.
73Ford Aerospace
74Fri.
75General Dynamics
76George Bush
77Headline News
78HOTOL
79I
80II
81III
82IV
83IX
84Institute of Technology
85JPL
86Jan.
87Jul.
88Jun.
89Kennedy Space Center
90LDEF
91Long Duration Exposure Facility
92Long March
93Mar.
94March
95Martin
96Martin Marietta
97Mercury
98Mon.
99in May
100s/\bmay (\d)/May $1/g;
101s/\boffice of (\w)/'Office of ' . (($tmp = $1) =~ y:a-z:A-Z:,$tmp)/eg;
102National Science Foundation
103NASA Select
104New Mexico
105Nov.
106OMB
107Oct.
108Office of Management and Budget
109President
110President Bush
111Richard Truly
112Rocketdyne
113Russian
114Russians
115Sat.
116Sep.
117Soviet
118Soviet Union
119Soviets
120Space Shuttle
121Sun.
122Thu.
123Tue.
124U.S.
125Union of Soviet Socialist Republics
126United States
127VI
128VII
129VIII
130Vice President
131Vice President Quayle
132Wed.
133White Sands
134Kaman Aerospace
135Aerospace Daily
136Aviation Week
137Space Technology
138Washington Post
139Los Angeles Times
140New York Times
141Aerospace Industries Association
142president of
143Johnson Space Center
144Space Services
145Inc.
146Co.
147Hughes Aircraft
148Company
149Orbital Sciences
150Swedish Space
151Arnauld
152Nicogosian
153Magellan
154Galileo
155Mir
156Jet Propulsion Laboratory
157University
158Department of Defense
159Orbital Science
160OMS
161United Press International
162United Press
163UPI
164Associated Press
165AP
166Cable News Network
167Cape York
168Zenit
169SYNCOM
170Eastern
171Western
172Test Range
173Jcsat
174Japanese Satellite Communications
175Defence Ministry
176Defense Ministry
177Skynet
178Fixed Service Structure
179Launch Processing System
180Asiasat
181Launch Control Center
182Earth
183CNES
184Glavkosmos
185Pacific
186Atlantic