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