#/usr/bin/perl
use strict;

# letzte Änderung: 19.04.2003
my $VERSION = 1.1;

my $file = $ARGV[0];

system("perl extract.pl \"$file\"");

$file = 'b_'.$file;

open (FILE, "<".$file) || die "Konnte $file nicht oeffnen: $!\n";
open (TARGET, ">".'hr_'.$file) || die "Konnte hr_$file nicht oeffnen: $!\n";
select (TARGET);

$file = join ('', <FILE>);

# alle Zahlen
$file =~ s/ 3(\d)/ [$1]/g;

# Gleichheitszeichen
$file =~ s/20/[ ]/g;
$file =~ s/21/[\!]/g;
$file =~ s/24/[\$]/g;
$file =~ s/2D/[\-]/g;
$file =~ s/2E/[\.]/g;
$file =~ s/3A/[:]/g;
$file =~ s/3D/[=]/g;
$file =~ s/5B/([)/g;
$file =~ s/5D/(])/g;

$file =~ s/22/["]/g;
$file =~ s/2C/[,]/g;
$file =~ s/27/[']/g;
$file =~ s/28/[(]/g;
$file =~ s/29/[)]/g;
$file =~ s/2F/[\/]/g;
$file =~ s/5C/[\\]/g;
$file =~ s/3B/[;]/g;
$file =~ s/3C/[<]/g;
$file =~ s/3E/[>]/g;
$file =~ s/3F/[\?]/g;


# Buchstaben
$file =~ s/41/[A]/g;
$file =~ s/42/[B]/g;
$file =~ s/43/[C]/g;
$file =~ s/44/[D]/g;
$file =~ s/45/[E]/g;
$file =~ s/46/[F]/g;
$file =~ s/47/[G]/g;
$file =~ s/48/[H]/g;
$file =~ s/49/[I]/g;
$file =~ s/4A/[J]/g;
$file =~ s/4B/[K]/g;
$file =~ s/4C/[L]/g;
$file =~ s/4D/[M]/g;
$file =~ s/4E/[N]/g;
$file =~ s/4F/[O]/g;
$file =~ s/50/[P]/g;
$file =~ s/51/[Q]/g;
$file =~ s/52/[R]/g;
$file =~ s/53/[S]/g;
$file =~ s/54/[T]/g;
$file =~ s/55/[U]/g;
$file =~ s/56/[V]/g;
$file =~ s/57/[W]/g;
$file =~ s/58/[X]/g;
$file =~ s/59/[Y]/g;
$file =~ s/5A/[Z]/g;
$file =~ s/61/[a]/g;
$file =~ s/62/[b]/g;
$file =~ s/63/[c]/g;
$file =~ s/64/[d]/g;
$file =~ s/65/[e]/g;
$file =~ s/66/[f]/g;
$file =~ s/67/[g]/g;
$file =~ s/68/[h]/g;
$file =~ s/69/[i]/g;
$file =~ s/6A/[j]/g;
$file =~ s/6B/[k]/g;
$file =~ s/6C/[l]/g;
$file =~ s/6D/[m]/g;
$file =~ s/6E/[n]/g;
$file =~ s/6F/[o]/g;
$file =~ s/70/[p]/g;
$file =~ s/71/[q]/g;
$file =~ s/72/[r]/g;
$file =~ s/73/[s]/g;
$file =~ s/74/[t]/g;
$file =~ s/75/[u]/g;
$file =~ s/76/[v]/g;
$file =~ s/77/[w]/g;
$file =~ s/78/[x]/g;
$file =~ s/79/[y]/g;
$file =~ s/7A/[z]/g;

$file =~ s/81/[ü]/g;
$file =~ s/84/[ä]/g;
$file =~ s/94/[ö]/g;
$file =~ s/E1/[ß]/g;

# Fixups
$file =~ s/ ->/->/g;
$file =~ s/7E7E/7E 7E/g;

$file =~ s/((?:\d|\w){2} )\[(.)\]( (?:\d|\w){2})/$1.sprintf("%02X", ord($2)).$3/eg;


$file =~ s/\] \[//g;


print $file;

select (STDOUT);
close (FILE);
close (TARGET);

