<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/afs/athena/contrib/perl/p
$debug =0;
$qline = '^[ \t]*[a-z]?[\-Q \W.]*[a-z]?\d[\d\.\-a-z]*[\W\.\):]*[ \t]+';

while(&lt;&gt;){
    print("%% $_") if $debug;
    if($body || $q){
	$body=0;
	if(/$qline((.+\?)+)[ \t]*$/){
	    print("\$q; $_\n") if $debug;
	    $question = $1;
	    &amp;qanda;
	}
	elsif(/^(Subject:|Q:)[ \[\]\d\.\-]+(.+)/){
	    print("\$sq; $_") if $debug;
	    $question = $2."\n";
	    $subj=1;
	}
	elsif($subj){
	    print("\$jq; $_\n") if $debug;
	    if(/^$/){
		$subj=0;
		&amp;qanda;
	    }
	    elsif($question=~/\?/){
		$subj=0;
		&amp;qanda;
		$answer .= $_;

	    }
	    else{
		$question .= $_;
	    }
	}
	elsif(/^(.+\?)[ \t]*$/){
	    print("\$oq; $_\n") if $debug;
	    $longq=1;
	    $lq = $1."\n";
	    $q=1;
	}
	elsif(/$qline(.+)/){
	    print("\$lq; $_\n") if $debug;
	    $longq=1;
	    $lq = $1."\n";
	    $q=1;
	}
	elsif($longq &amp;&amp; /((.+\?)+)[ \t]*$/){
	    print("\$eq; $_\n") if $debug;
	    &amp;lqanda;
	}
	elsif($longq &amp;&amp; /^$/){
	    print("\$bq; $_\n") if $debug;
	    if($lq=~/\?/){
		&amp;lqanda;
	    }
	    elsif(length($lq)&lt;100){
		&amp;lqanda;
	    }
	    else{
		print("\$nq; $_\n") if $debug;
		$answer.=$lq;
	    }
	    $lq='';
	    $longq=0;
	}
	elsif($longq){
	    print("\$iq; $_\n") if $debug;
	    $lq.=$_;
	}
	else{
	    print("\$;; $_\n") if $debug;
	    $answer .= $_;
	}
    }else{
	print(":::: $_") if $debug;
	$answer='';
	$body =1 if /^$/;
	$q =1 if /^$/;
    }
}
&amp;doa;


sub qanda {
    $answer.=$lq;
    &amp;doa;
    &amp;doq;
}
sub doa {
    $longq=0;
    if($answer &amp;&amp; $pquestion){print("$pquestion\n$answer\n");}
#    else{print("No Answer\n");}
    
}
sub doq{
    $answer='';
    $stars = "*"x30;
    $pquestion = "\n$stars\n$question\n$stars\n";

}
sub lqanda{
    &amp;doa;
    $question = $lq.$_;
    &amp;doq;
}


</pre></body></html>