#!/usr/bin/perl -w # Myst Shen, June,2008.
use Fcntl;
use SDBM_File;
use Data::Dumper;
# hash
tie (%h, 'SDBM_File', ' data_file ', O_RDWR|O_CREAT, 0640) || die $!;
# foreach (<>) {
# push (@words, split);
# }
# %h = @words;
# pretty printing
print Data::Dumper->Dump([\%h], [qw(\%h)]);
# other stuff
$k0 = "A";
while (($k,$v) = each (%h)) {
if ($k =~ "A"){
next;
}
$v =~ s/0/2/g;
$v =~ s/1/0/g;
$v =~ s/2/1/g;
$v0 = $h{$k0} ;
print "$k0 ";
for ($i=1; $i<=6; $i++) {
if (substr ($v,-$i,1) == substr ($v0,$i-1,1)) {
next;
}
else {
print $i;
}
}
print " $k";
$k0 = $k;
print "\n";
}
|