#! /usr/bin/perl
# perlx File [File ...]
#
#  copies the runperl.bat script from the "strawberry" Perl distribution 
#    to [a list of] File.bat so that on MS windows typing just "File" 
#    will execute that perl script
#  If File has an extension it must exist and be newer than the stripped name,
#    then a copy is made under the stripped name and that one will be run.
#    Otherwise, no action.

use File::Copy;

$i = 0;
FFF:
while (defined($ARGV[$i])) { #do for all files
  $f = $ARGV[$i++];  #to save typing and free $i
  $g = $f;
  if ($f =~ /\./) {
    @whole = split('\.',$f);  #assume XXX.YYY
    $g = $whole[0];
    if (-e $f && (!-e $g || (-M $f < -M $g))) {
      copy($f,$g);
    } else {
      print "No action:  which of $f or $g should be used?\n";
      next FFF;
    }
  }
  copy("runperl.bat","$g.bat");
}
if ($i == 0) { #no File(s)
  print "A [list of] File(s) must be supplied\n";
}
