This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl.h: Add comments
[perl5.git] / utils / splain.PL
CommitLineData
5f05dabc 1#!/usr/local/bin/perl
2
ce957b55
N
3use strict;
4use warnings;
5
5f05dabc 6use Config;
7use File::Basename qw(&basename &dirname);
d5201bd2 8use File::Spec;
8a5546a1 9use Cwd;
5f05dabc 10
11# List explicitly here the variables you want Configure to
12# generate. Metaconfig only looks for shell variables, so you
13# have to mention them as if they were shell variables, not
14# %Config entries:
15# $startperl
16# $perlpath
17# $eunicefix
18
19# This forces PL files to create target in same directory as PL file.
20# This is so that make depend always knows where to find PL derivatives.
ce957b55 21my $origdir = cwd;
44a8e56a 22chdir dirname($0);
ce957b55 23my $file = basename($0, '.PL');
774d564b 24$file .= '.com' if $^O eq 'VMS';
5f05dabc 25
26# Open input file before creating output file.
ce957b55 27my $in = File::Spec->catfile(File::Spec->updir, 'lib', 'diagnostics.pm');
1ae6ead9 28open IN, '<', $in or die "Can't open $in: $!\n";
5f05dabc 29
30# Create output file.
1ae6ead9 31open OUT, '>', $file or die "Can't create $file: $!";
5f05dabc 32
33print "Extracting $file (with variable substitutions)\n";
34
35# In this section, perl variables will be expanded during extraction.
36# You can use $Config{...} to use Configure variables.
37
38print OUT <<"!GROK!THIS!";
39$Config{startperl}
40 eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
188e64dd 41 if 0; # ^ Run only under a shell
5f05dabc 42!GROK!THIS!
43
2c25177b 44print OUT <<'!NO!SUBS!';
cee96d52
TC
45
46BEGIN { pop @INC if $INC[-1] eq '.' }
47
48!NO!SUBS!
49
5f05dabc 50while (<IN>) {
51 print OUT unless /^package diagnostics/;
52}
53
54close IN;
55
56close OUT or die "Can't close $file: $!";
57chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
58exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';
8a5546a1 59chdir $origdir;