1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
|
#!/usr/local/bin/perl
use Config;
use File::Basename qw(&basename &dirname);
use Cwd;
# List explicitly here the variables you want Configure to
# generate. Metaconfig only looks for shell variables, so you
# have to mention them as if they were shell variables, not
# %Config entries. Thus you write
# $startperl
# to ensure Configure will look for $Config{startperl}.
# This forces PL files to create target in same directory as PL file.
# This is so that make depend always knows where to find PL derivatives.
$origdir = cwd;
chdir(dirname($0));
($file = basename($0)) =~ s/\.PL$//;
$file =~ s/\.pl$// if ($^O eq 'os2' or $^O eq 'dos'); # "case-forgiving"
$file =~ s/\.pl$/.com/ if ($^O eq 'VMS'); # "case-forgiving"
open OUT,">$file" or die "Can't create $file: $!";
print "Extracting $file (with variable substitutions)\n";
# In this section, perl variables will be expanded during extraction.
# You can use $Config{...} to use Configure variables.
print OUT <<"!GROK!THIS!";
$Config{'startperl'}
eval 'exec perl -S \$0 "\$@"'
if 0;
!GROK!THIS!
# In the following, perl variables are not expanded during extraction.
print OUT <<'!NO!SUBS!';
#
# buildtoc
#
# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
# This file is autogenerated by buildtoc.PL.
# Edit that file and run it to effect changes.
#
# Builds perltoc.pod and sanity checks the list of pods against all
# of the MANIFEST, perl.pod, and ourselves.
#
use File::Find;
use Cwd;
use Text::Wrap;
@PODS = glob("*.pod");
sub output ($);
if (-d "pod") {
die "$0: failed to chdir('pod'): $!\n" unless chdir("pod");
}
@ARCHPODS = qw(
perlaix
perlapollo
perlamiga
perlbeos
perlbs2000
perlce
perlcygwin
perldgux
perldos
perlepoc
perlfreebsd
perlhpux
perlhurd
perlirix
perlmachten
perlmacos
perlmint
perlmpeix
perlnetware
perlos2
perlos390
perlos400
perlqnx
perlplan9
perlsolaris
perltru64
perluts
perlvmesa
perlvms
perlvos
perlwin32
);
@CJKPODS = qw(
perlcn
perljp
perlko
perltw
);
@pods =
(
qw(
perl
perlintro
perlfaq
perltoc
perlbook
perlsyn
perldata
perlop
perlsub
perlfunc
perlreftut
perldsc
perlrequick
perlpod
perlpodspec
perlstyle
perltrap
perlrun
perldiag
perllexwarn
perldebtut
perldebug
perlvar
perllol
perlopentut
perlpacktut
perlretut
perlre
perlref
perlform
perlboot
perltoot
perltooc
perlobj
perlbot
perltie
perlipc
perlfork
perlnumber
perlthrtut
perlothrtut
perlport
perllocale
perluniintro
perlunicode
perlebcdic
perlsec
perlmod
perlmodinstall
perlmodlib
perlmodstyle
perlnewmod
perlfaq1
perlfaq2
perlfaq3
perlfaq4
perlfaq5
perlfaq6
perlfaq7
perlfaq8
perlfaq9
perlcompile
perlembed
perldebguts
perlxstut
perlxs
perlclib
perlguts
perlcall
perlutil
perlfilter
perldbmfilter
perlapi
perlintern
perliol
perlapio
perltodo
perlhack
perlhist
perldelta
perl572delta
perl571delta
perl570delta
perl561delta
perl56delta
perl5005delta
perl5004delta
),
@ARCHPODS,
);
for (@ARCHPODS) { s/$/.pod/ }
@ARCHPODS{@ARCHPODS} = ();
for (@CJKPODS) { s/$/.pod/ }
@CJKPODS{@CJKPODS} = ();
for (@pods) { s/$/.pod/ }
@pods{@pods} = ();
@PODS{@PODS} = ();
open(MANI, "../MANIFEST") || die "$0: opening ../MANIFEST failed: $!";
while (<MANI>) {
if (m!^pod/([^.]+\.pod)\s+!i) {
push @MANIPODS, $1;
}
}
close(MANI);
@MANIPODS{@MANIPODS} = ();
open(PERLPOD, "perl.pod") || die "$0: opening perl.pod failed: $!\n";
while (<PERLPOD>) {
if (/^For ease of access, /../^\(If you're intending /) {
if (/^\s+(perl\S*)\s+\w/) {
push @PERLPODS, "$1.pod";
}
}
}
close(PERLPOD);
die "$0: could not find the pod listing of perl.pod\n"
unless @PERLPODS;
@PERLPODS{@PERLPODS} = ();
# Delete the CJK because we cannot mix their encodings.
delete @PERLPODS{@CJKPODS};
delete @PODS{@CJKPODS};
delete @pods{@CJKPODS};
# Cross-check against ourselves
# Cross-check against the MANIFEST
# Cross-check against the perl.pod
foreach my $i (sort keys %PODS) {
warn "$0: $i exists but is unknown by buildtoc\n"
unless exists $pods{$i};
warn "$0: $i exists but is unknown by ../MANIFEST\n"
if !exists $MANIPODS{$i} && !exists $ARCHPODS{$i} && !exists $CJKPODS{$i};
warn "$0: $i exists but is unknown by perl.pod\n"
unless exists $PERLPODS{$i};
}
foreach my $i (sort keys %pods) {
warn "$0: $i is known by buildtoc but does not exist\n"
unless exists $PODS{$i};
}
foreach my $i (sort keys %MANIPODS) {
warn "$0: $i is known by ../MANIFEST but does not exist\n"
unless exists $PODS{$i};
}
foreach my $i (sort keys %PERLPODS) {
warn "$0: $i is known by perl.pod but does not exist\n"
unless exists $PODS{$i};
}
# We are ready to rock.
open(OUT, ">perltoc.pod") || die "$0: creating perltoc.pod failed: $!";
$/ = '';
@ARGV = @pods;
($_= <<EOPOD2B) =~ s/^\t//gm && output($_);
=head1 NAME
perltoc - perl documentation table of contents
=head1 DESCRIPTION
This page provides a brief table of contents for the rest of the Perl
documentation set. It is meant to be scanned quickly or grepped
through to locate the proper section you're looking for.
=head1 BASIC DOCUMENTATION
EOPOD2B
#' make emacs happy
podset(@pods);
find \&getpods => qw(../lib ../ext);
sub getpods {
if (/\.p(od|m)$/) {
my $file = $File::Find::name;
return if $file eq '../lib/Pod/Functions.pm'; # Used only by pod itself
return if $file =~ m!lib/Attribute/Handlers/demo/!;
return if $file =~ m!lib/Net/FTP/.+\.pm!; # Hi, Graham! :-)
return if $file =~ m!lib/Math/BigInt/t/!;
return if $file =~ m!/Devel/PPPort/[Hh]arness|lib/Devel/Harness!i;
return if $file =~ m!XS/(?:APItest|Typemap)!;
die "tut $name" if $file =~ /TUT/;
unless (open (F, "< $_\0")) {
warn "bogus <$file>: $!";
system "ls", "-l", $file;
}
else {
my $line;
while ($line = <F>) {
if ($line =~ /^=head1\s+NAME\b/) {
push @modpods, $file;
#warn "GOOD $file\n";
return;
}
}
warn "$0: $file: cannot find =head1 NAME\n";
}
}
}
die "no pods" unless @modpods;
for (@modpods) {
#($name) = /(\w+)\.p(m|od)$/;
$name = path2modname($_);
if ($name =~ /^[a-z]/) {
push @pragmata, $_;
} else {
if ($done{$name}++) {
# warn "already did $_\n";
next;
}
push @modules, $_;
push @modname, $name;
}
}
($_= <<EOPOD2B) =~ s/^\t//gm && output($_);
=head1 PRAGMA DOCUMENTATION
EOPOD2B
podset(sort @pragmata);
($_= <<EOPOD2B) =~ s/^\t//gm && output($_);
=head1 MODULE DOCUMENTATION
EOPOD2B
podset( @modules[ sort { $modname[$a] cmp $modname[$b] } 0 .. $#modules ] );
($_= <<EOPOD2B) =~ s/^\t//gm;
=head1 AUXILIARY DOCUMENTATION
Here should be listed all the extra programs' documentation, but they
don't all have manual pages yet:
=over 4
=item a2p
=item s2p
=item find2perl
=item h2ph
=item c2ph
=item h2xs
=item xsubpp
=item pod2man
=item wrapsuid
=back
=head1 AUTHOR
Larry Wall <F<larry\@wall.org>>, with the help of oodles
of other folks.
EOPOD2B
output $_;
output "\n"; # flush $LINE
exit;
sub podset {
local @ARGV = @_;
while(<>) {
if (s/^=head1 (NAME)\s*/=head2 /) {
$pod = path2modname($ARGV);
unhead1();
output "\n \n\n=head2 ";
$_ = <>;
if ( /^\s*$pod\b/ ) {
s/$pod\.pm/$pod/; # '.pm' in NAME !?
output $_;
} else {
s/^/$pod, /;
output $_;
}
next;
}
if (s/^=head1 (.*)/=item $1/) {
unhead2();
output "=over 4\n\n" unless $inhead1;
$inhead1 = 1;
output $_; nl(); next;
}
if (s/^=head2 (.*)/=item $1/) {
unitem();
output "=over 4\n\n" unless $inhead2;
$inhead2 = 1;
output $_; nl(); next;
}
if (s/^=item ([^=].*)/$1/) {
next if $pod eq 'perldiag';
s/^\s*\*\s*$// && next;
s/^\s*\*\s*//;
s/\n/ /g;
s/\s+$//;
next if /^[\d.]+$/;
next if $pod eq 'perlmodlib' && /^ftp:/;
##print "=over 4\n\n" unless $initem;
output ", " if $initem;
$initem = 1;
s/\.$//;
s/^-X\b/-I<X>/;
output $_; next;
}
if (s/^=cut\s*\n//) {
unhead1();
next;
}
}
}
sub path2modname {
local $_ = shift;
s/\.p(m|od)$//;
s-.*?/(lib|ext)/--;
s-/-::-g;
s/(\w+)::\1/$1/;
return $_;
}
sub unhead1 {
unhead2();
if ($inhead1) {
output "\n\n=back\n\n";
}
$inhead1 = 0;
}
sub unhead2 {
unitem();
if ($inhead2) {
output "\n\n=back\n\n";
}
$inhead2 = 0;
}
sub unitem {
if ($initem) {
output "\n\n";
##print "\n\n=back\n\n";
}
$initem = 0;
}
sub nl {
output "\n";
}
my $NEWLINE; # how many newlines have we seen recently
my $LINE; # what remains to be printed
sub output ($) {
for (split /(\n)/, shift) {
if ($_ eq "\n") {
if ($LINE) {
print OUT wrap('', '', $LINE);
$LINE = '';
}
if ($NEWLINE < 2) {
print OUT;
$NEWLINE++;
}
}
elsif (/\S/ && length) {
$LINE .= $_;
$NEWLINE = 0;
}
}
}
!NO!SUBS!
close OUT or die "Can't close $file: $!";
chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
chdir $origdir;
|