splain.PL revision 1.7
1#!/usr/local/bin/perl 2 3use strict; 4use warnings; 5 6use Config; 7use File::Basename qw(&basename &dirname); 8use File::Spec; 9use Cwd; 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. 21my $origdir = cwd; 22chdir dirname($0); 23my $file = basename($0, '.PL'); 24$file .= '.com' if $^O eq 'VMS'; 25 26# Open input file before creating output file. 27my $in = File::Spec->catfile(File::Spec->updir, 'lib', 'diagnostics.pm'); 28open IN, '<', $in or die "Can't open $in: $!\n"; 29 30# Create output file. 31open OUT, '>', $file or die "Can't create $file: $!"; 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+"\$@"}' 41 if \$running_under_some_shell; 42!GROK!THIS! 43 44print OUT <<'!NO!SUBS!'; 45 46BEGIN { pop @INC if $INC[-1] eq '.' } 47 48!NO!SUBS! 49 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 ':'; 59chdir $origdir; 60