Код:
#!/usr/bin/perl
if (@ARGV < 1)
{
print "Usage: transkey.pl source\r\n";
exit();
}
$sour = $ARGV[0];
if (@ARGV = 1){
$dest = $sour . '_trans';
}
else{
$dest = $ARGV[1];
};
$alphabet = "f,dult;pbqrkvyjghcnea[wxio]sm'.z";
$alphabet2 = 'F<DULT:PBQRKVYJGHCNEA{WXIO}SM">Z';
open (SR, "<$sour") || die "Could not open source file";
open (DS, ">$dest") || die "Could not create destination file";
while (<SR>){
chomp;
@bukvy = split(//);
foreach $bk (@bukvy) {
$num = ord($bk);
if ($num < 256){
if ($num > 223){
$bk = substr($alphabet,$num-224,1);
}else{
if ($num > 191){
$bk = substr($alphabet2,$num-192,1);
};
};
};
}
print DS join("",@bukvy) . "\n";
};
close (SR);
close (DS);