#!/usr/bin/perl
$^I = ".bak" ;

open (IN,@ARGV[0]) || die "Can't open @ARGV[0]";
while (<IN>) {
  chop ;
  if (/<h2>/) {
    print "got H2\n";
    s/<h2>// ; s%</h2>%% ;
    $descr = $_ ;
  }
}
$file = $ARGV[0] ;
@ARGV = ($file) ; # prime diamond operator for inplace edit
while (<>) {
  chop ;
  if (/<head>/) {
    print "$_\n";
    print "<META NAME=\"description\" CONTENT=\"$descr\">\n"
  } else {
    print "$_\n";
  }
}
