home *** CD-ROM | disk | FTP | other *** search
- @rem = '-*- Perl -*-';
- @rem = '
- @echo off
- perl %0.cmd %1 %2 %3 %4 %5 %6 %7 %8 %9
- goto endofperl
- ';
- #
- # ntcvt.cmd - convert a unix perl script to an NT perl script
- #
-
- &usage if $#ARGV < 0;
-
- $infile = $ARGV[0];
-
- open (I, $infile) || die "Can't open $infile for reading: $!";
- @lines = <I>;
- close I;
-
- if ($lines[0] =~ /^#!.*perl/) {
- if ($lines[0] =~ /^#!.*perl\s+\S+$/) {
- ($switches = $lines[0]) =~ s/^#!.*perl\s+-(\S+).*$/-$1/;
- chop ($switches);
- }
- # $switches = "-S" if $switches eq "";
- shift (@lines);
- }
-
- @header = ('@rem = \'-*- Perl -*-\';',
- '@rem = \'',
- '@echo off',
- "perl $switches %0.cmd %1 %2 %3 %4 %5 %6 %7 %8 %9",
- 'goto endofperl',
- '\';');
-
- @path = split(m;[\\/];, $infile);
-
- $file = $path[$#path];
-
- $newfile = &makecmd($file, join('/', @path[0..$#path-1]));
-
- open (O, ">$newfile") || die "Can't open $newfile for output: $!";
- print O join("\n", @header);
- print O @lines;
- print O "__END__\n:endofperl\n";
- close O;
-
- print "$infile converted to $newfile\n";
-
- sub makecmd {
- local($file, $path) = @_;
- local($newfile) = $file;
-
- #
- # translate any dots in the name to '_'
- #
-
- $newfile =~ tr/\./_/;
- $newfile = substr($newfile, 0, 8);
- while( -e "$path/$newfile.cmd") {
- substr($newfile, -1, 1) = "~";
- }
- "$newfile.cmd";
- }
-
- sub usage {
- print STDERR "ntcvt scriptname
-
- __END__
- :endofperl
-