#!/usr/bin/perl

my $from, $to;

foreach $fn (<*.chs>) {
  $from=""; $to="";
  if( open(F, $fn) ) {
    my $c=0;
    while(!eof(F) || $c<5){
      $_=<F>;
      chomp;
      next if( /^;/ );
      next if( /^$/ );
      s/\s*;.*$//;
      if( /^([0-9A-Z_-]+)/i ){
         $c++;
         if($c==4){
            $from=$1;
         }
         elsif($c==5){
            $to=$1;
         }
      }
    }
    close F;
    if($from eq $to){
      print "$fn   Charset conversion table from $from to $to (no conversion)\n";
    }else{
      print "$fn   Charset conversion table from $from to $to\n";
    }
  }
}

