$linelistfile = "glf1.lst";

open(LOGFILE, ">>glf1.log");
$start_time = time;
print(LOGFILE "\nUnix time: $start_time  Line List: $linelistfile\n");
open(LINELIST, "<$linelistfile");
while ( <LINELIST> )
{
   ($filename, $line_number, $line) = split(/:/);
#   print "$filename  $line_number -- $line";
   if ($line_number >= 1)
   {  $lineset{$filename} = "$lineset{$filename} $line_number";}
}
close(LINELIST);

foreach $fn (sort(keys(%lineset)))
{
   print (LOGFILE "$fn $lineset{$fn}\n");
   @lines = split(" ", $lineset{$fn});
   $fnsource = "${fn}l";
   rename($fn, $fnsource);
   open(SOURCE, "<$fnsource") || die("Can't open $fnsource.\n");
   open(DEST, ">$fn") || die("Can't open $fn.\n");
   $line_number = 0;
   $edit_line = shift(@lines);
   while ( <SOURCE> )
   {
      $line_number++;
      if ($line_number == $edit_line)
      {
         print(LOGFILE "$line_number:\n");
         print(LOGFILE $_);
         $substitutions = s/(%[\d\*]*\.?[\d\*]*)(l)([fg])/$1$3/g;
         print(LOGFILE $_);
         print(LOGFILE "$substitutions\n\n");
         $edit_line = shift(@lines);
      }
      print(DEST $_);
   }
   close(SOURCE);
   close(DEST);
}
$end_time = time;
print(LOGFILE "Unix time: $end_time\n\n");
close(LOGFILE);

