#!/usr/local/bin/perl/perl
#
# Jerome C. Parks
# June 25, 1996

$list = "list.txt";
$end = "end.txt";
$temp = "Temp.txt";
$length = "length.txt";

system "ls 9* > $list";
open(IN,"$list") || warn "Can't open $list for read";
chop(@f=<IN>);
close IN;

foreach $file (@f) {
  print "\$file: $file\n";
  system "wc \-l $file \> $length";
  if ($?) { print "wc error: $!\n"; }
  open(IN,"$length") || warn "Can't open $length for read";
  @h=<IN>;
  close IN;
  print "Length: @h[0]\n";
  
  @i = split(/\s+/,@h[0]);
  print "Number: @i[1]\t";
  $count = (@i[1]-20);
  print "Lines: $count\n";
  system "head \-$count $file \> $temp";
  if ($?) { print "head error: $!\n"; }
  system "rm $file";
  if ($?) { print "rm error: $!\n"; }
  $file=~s/html/shtml/;
  system "cat $temp $end \> $file";
  if ($?) { print "cat error: $!\n"; }
  system "cp $file $file.BAK";
  if ($?) { print "cp error: $!\n"; }

}

exit;

