This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix use of == to compare strings in perlref.pod
[perl5.git] / pod / perlmodlib.PL
index 36990f9..608b64e 100644 (file)
@@ -5,35 +5,47 @@ use warnings;
 
 $ENV{LC_ALL} = 'C';
 
-use FindBin;
-chdir $FindBin::Bin or die "$0: Can't chdir $FindBin::Bin: $!";
+my $Quiet;
+@ARGV = grep { not($_ eq '-q' and $Quiet = 1) } @ARGV;
 
-my $Quiet = @ARGV && $ARGV[0] eq '-q';
-
-open (OUT, ">perlmodlib.pod") or die $!;
-my (@pragma, @mod, @files);
+if (@ARGV) {
+    my $workdir = shift;
+    chdir $workdir
+        or die "Couldn't chdir to '$workdir': $!";
+}
+require 'regen/regen_lib.pl';
 
 # MANIFEST itself is Unix style filenames, so we have to assume that Unix style
 # filenames will work.
 
-open (MANIFEST, "../MANIFEST") or die $!;
-@files = grep m#(?:\.pm|\.pod|_pm\.PL)#, map {s/\s.*//s; $_}
-    grep { m#^(lib|ext|dist|cpan)/# && !m#/(?:t|demo)/# } <MANIFEST>;
+open MANIFEST, '<', 'MANIFEST'
+    or die "Can't open MANIFEST: $!";
+my @files =
+    grep !m#/perl.*\.pod#,
+    grep m#(?:\.pm|\.pod|_pm\.PL)#,
+    map {s/\s.*//s; $_}
+    grep { m#^(lib|ext|dist|cpan)/# && !m#/(?:t|demo)/# }
+    <MANIFEST>;
+close MANIFEST
+    or die "$0: failed to close MANIFEST: $!";
+
+my $out = open_new('pod/perlmodlib.pod', undef,
+                   {by => "$0 extracting documentation",
+                    from => 'the Perl source files'}, 1);
 
 my %exceptions = (
     'abbrev' => 'Text::Abbrev',
     'carp' => 'Carp',
     'getopt' => 'Getopt::Std',
-    'B<CGI::Carp>' => 'CGI::Carp',
-    'ModuleInfo' => 'Module::Build::ModuleInfo',
-    '$notes_name' => 'Module::Build::Notes',
     'Encode::MIME::NAME' => 'Encode::MIME::Name',
     'libnetFAQ' => 'Net::libnetFAQ',
 );
 
+my (@pragma, @mod);
+
 for my $filename (@files) {
-    unless (open MOD, '<', "../$filename") {
-       warn "Couldn't open ../$filename: $!";
+    unless (open MOD, '<', $filename) {
+        warn "Couldn't open $filename: $!";
        next;
     }
 
@@ -54,7 +66,8 @@ for my $filename (@files) {
     }
     my $title = <MOD>;
     chomp $title;
-    close MOD;
+    close MOD
+        or die "Error closing $filename: $!";
 
     ($name, $thing) = split / --? /, $title, 2;
 
@@ -89,10 +102,7 @@ push @mod, "=item Config\n\nAccess Perl configuration information\n\n";
 # makes it tidier, by stopping anything doing this mistaking the rest of the
 # Perl code for Pod. eg http://search.cpan.org/dist/perl/pod/perlmodlib.PL
 
-print OUT <<'=cut';
-=for maintainers
-Generated by perlmodlib.PL -- DO NOT EDIT!
-
+print $out <<'=cut';
 =head1 NAME
 
 perlmodlib - constructing new Perl modules and finding existing ones
@@ -141,9 +151,9 @@ The following pragmas are defined (and have their own documentation).
 
 =cut
 
-print OUT $_ for (sort @pragma);
+print $out $_ for sort @pragma;
 
-print OUT <<'=cut';
+print $out <<'=cut';
 
 =back
 
@@ -161,9 +171,9 @@ don't have the gdbm library.
 
 =cut
 
-print OUT $_ for (sort @mod);
+print $out $_ for sort @mod;
 
-print OUT <<'=cut';
+print $out <<'=cut', "=cut\n";
 
 =back
 
@@ -1510,6 +1520,4 @@ you're redefining the world and willing to take the consequences.
 
 =cut
 
-close MANIFEST or warn "$0: failed to close MANIFEST (../MANIFEST): $!";
-close OUT      or warn "$0: failed to close OUT (perlmodlib.pod): $!";
-
+read_only_bottom_close_and_rename($out);