#!/usr/bin/perl -w

## Create Perl code from first argument (-e CODE)
eval "sub replace { $ARGV[0]; }";
shift @ARGV;

foreach $fname (@ARGV)
{
  rename ($fname, "$fname.bak") or die "Rename failed:$fname:$!"; 
  open (my $FHI, "<", "$fname.bak") or die "Open failed:$fname.bak:$!";  
  open (my $FHO, ">", "$fname") or die "Open failed:$fname:$!";  

  while (<$FHI>)
  {
    replace ();
    print $FHO $_;      
  }

  close ($FHI);
  close ($FHO);
  unlink "$fname.bak" or die "Delete failed:$fname.bak:$!";
}
