This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Document eval vs. sub in Benchmark
[perl5.git] / pod / pod2text.PL
1 #!/usr/local/bin/perl
2
3 use Config;
4 use 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.  Thus you write
10 #  $startperl
11 # to ensure Configure will look for $Config{startperl}.
12
13 # This forces PL files to create target in same directory as PL file.
14 # This is so that make depend always knows where to find PL derivatives.
15 chdir dirname($0);
16 $file = basename($0, '.PL');
17 $file .= '.com' if $^O eq 'VMS';
18
19 open OUT,">$file" or die "Can't create $file: $!";
20
21 print "Extracting $file (with variable substitutions)\n";
22
23 # In this section, perl variables will be expanded during extraction.
24 # You can use $Config{...} to use Configure variables.
25
26 print OUT <<"!GROK!THIS!";
27 $Config{startperl}
28     eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}'
29         if \$running_under_some_shell;
30 !GROK!THIS!
31
32 # In the following, perl variables are not expanded during extraction.
33
34 print OUT <<'!NO!SUBS!';
35
36 use Pod::Text;
37
38 if(@ARGV) {
39         pod2text($ARGV[0]);
40 } else {
41         pod2text("<&STDIN");
42 }
43
44 !NO!SUBS!
45
46 close OUT or die "Can't close $file: $!";
47 chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
48 exec("$Config{'eunicefix'} $file") if $Config{'eunicefix'} ne ':';