#!/usr/bin/perl


$file=$ARGV[0];

# make a backup copy
$tmpfile="/tmp/wee.".time().'.'.$$;

system ("cp -p $file $tmpfile");
system ("mtc -s -f win1251 -t koi8 $tmpfile");

system("ee $tmpfile");

system ("mtc -s -f koi8 -t win1251 $tmpfile");

$a=system("cmp -s $file $tmpfile");
$a=$a/256;

if ($a>0){
	# modified
	rename $file, $file.'.b';
	system ("mv $tmpfile $file");
}
