X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=x2p%2Fs2p.PL;h=73f67872de1bf098529d0431dce95daa723ed0bb;hb=d121ca8cbe925d3e532e9c845f6853715e75724a;hp=4f7293d4c23d37733fdd2edcf33dce5ae3d1cbf5;hpb=f70b6ff5dbae63778d9b1ac9a297c2d960e64cbf;p=p5sagit%2Fp5-mst-13.2.git diff --git a/x2p/s2p.PL b/x2p/s2p.PL index 4f7293d..73f6787 100644 --- a/x2p/s2p.PL +++ b/x2p/s2p.PL @@ -12,11 +12,9 @@ use File::Basename qw(&basename &dirname); # This forces PL files to create target in same directory as PL file. # This is so that make depend always knows where to find PL derivatives. -chdir(dirname($0)); -($file = basename($0)) =~ s/\.PL$//; -$file =~ s/\.pl$// - if ($Config{'osname'} eq 'VMS' or - $Config{'osname'} eq 'OS2'); # "case-forgiving" +chdir dirname($0); +$file = basename($0, '.PL'); +$file .= '.com' if $^O eq 'VMS'; open OUT,">$file" or die "Can't create $file: $!"; @@ -26,10 +24,11 @@ print "Extracting $file (with variable substitutions)\n"; # You can use $Config{...} to use Configure variables. print OUT <<"!GROK!THIS!"; -$Config{'startperl'} - eval 'exec perl -S \$0 "\$@"' - if 0; +$Config{startperl} + eval 'exec $Config{perlpath} -S \$0 \${1+"\$@"}' + if \$running_under_some_shell; \$startperl = "$Config{startperl}"; +\$perlpath = "$Config{perlpath}"; !GROK!THIS! # In the following, perl variables are not expanded during extraction. @@ -40,6 +39,78 @@ print OUT <<'!NO!SUBS!'; # # $Log: s2p.SH,v $ +=head1 NAME + +s2p - Sed to Perl translator + +=head1 SYNOPSIS + +B + +=head1 DESCRIPTION + +I takes a sed script specified on the command line (or from +standard input) and produces a comparable I script on the +standard output. + +=head2 Options + +Options include: + +=over 5 + +=item B<-DEnumberE> + +sets debugging flags. + +=item B<-n> + +specifies that this sed script was always invoked with a B. +Otherwise a switch parser is prepended to the front of the script. + +=item B<-p> + +specifies that this sed script was never invoked with a B. +Otherwise a switch parser is prepended to the front of the script. + +=back + +=head2 Considerations + +The perl script produced looks very sed-ish, and there may very well +be better ways to express what you want to do in perl. For instance, +s2p does not make any use of the split operator, but you might want +to. + +The perl script you end up with may be either faster or slower than +the original sed script. If you're only interested in speed you'll +just have to try it both ways. Of course, if you want to do something +sed doesn't do, you have no choice. It's often possible to speed up +the perl script by various methods, such as deleting all references to +$\ and chop. + +=head1 ENVIRONMENT + +S2p uses no environment variables. + +=head1 AUTHOR + +Larry Wall EFE + +=head1 FILES + +=head1 SEE ALSO + + perl The perl compiler/interpreter + + a2p awk to perl translator + +=head1 DIAGNOSTICS + +=head1 BUGS + +=cut + $indent = 4; $shiftwidth = 4; $l = '{'; $r = '}'; @@ -295,7 +366,7 @@ unless ($debug) { print &q(<<"EOT"); : $startperl -: eval 'exec perl -S \$0 \${1+"\$@"}' +: eval 'exec $perlpath -S \$0 \${1+"\$@"}' : if \$running_under_some_shell; : EOT