[inseparable changes from patch from perl5.003_12 to perl5.003_13]
[p5sagit/p5-mst-13.2.git] / utils / splain.PL
CommitLineData
5f05dabc 1#!/usr/local/bin/perl
2
3use Config;
4use File::Basename qw(&basename &dirname);
5
6# List explicitly here the variables you want Configure to
7# generate. Metaconfig only looks for shell variables, so you
8# have to mention them as if they were shell variables, not
9# %Config entries:
10# $startperl
11# $perlpath
12# $eunicefix
13
14# This forces PL files to create target in same directory as PL file.
15# This is so that make depend always knows where to find PL derivatives.
16chdir(dirname($0));
17($file = basename($0)) =~ s/\.PL$//;
18$file =~ s/\.pl$//
19 if ($^O eq 'VMS' or $^O eq 'os2'); # "case-forgiving"
20
21# Open input file before creating output file.
22$IN = '../lib/diagnostics.pm';
23open IN or die "Can't open $IN: $!\n";
24
25# Create output file.
26open OUT,">$file" or die "Can't create $file: $!";
27
28print "Extracting $file (with variable substitutions)\n";
29
30# In this section, perl variables will be expanded during extraction.
31# You can use $Config{...} to use Configure variables.
32
33print OUT <<"!GROK!THIS!";
34$Config{startperl}
35 eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
36 if \$running_under_some_shell;
37!GROK!THIS!
38
39while (<IN>) {
40 print OUT unless /^package diagnostics/;
41}
42
43close IN;
44
45close OUT or die "Can't close $file: $!";
46chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
47exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';