#!/afs/athena/contrib/perl/p
#
$st = 256;
undef($/);
$line = (<>);
@chars = split(//, $line);
foreach $k (@chars){
    if(defined($dict{$w.$k})){
#	print("$w$k found in dictionary.  Restting w to $w$k\n");
	$w = $w.$k;
    }
    else{
#	print("$w$k not in dictionary.  Printing -$dict{$w}-\n");
#	print("Adding table entry as $st and setting w=$k;\n");
#	if($dict{$w}){$output .=$dict{$w};}
#	else{$output.=$w;}
	if($dict{$w} eq ''){push(@out, ord($w)) if $w;}
	else{push(@out, $dict{$w});}
	if($w){
	    $dict{$w.$k}=$st;
#	    print(";$dict{$w.$k}==$w$k\n");
	    $st++;
	}
	$w=$k;
    }
}
#print("Translating\n");
foreach $sym (@out){
#    print $sym."\n";
    $bitst = unpack('B16', pack('n', $sym));
#    print(substr($bitst, 7)."\n");
    $bits .= substr($bitst, 7);
}
#print("Bits is complete\n");
$bits=$bits.'00000000';
#print(substr($bits, 0, 22));
for $printthis (split(/(........)/, $bits)){
#    print("\nTrying $printthis:");
    print pack('B8', $printthis) if $printthis;
}
__END__




