in reply to Keys beside keys on keyboards
Here's how I'd do it:
# keyboard sequence (qwertz), for request from germany my $k = <<EOH; 1234567890ß' !"§$%&/()=?` qwertzuiopü+ asdfghjklöä# <yxcvbnm,.- >YXCVBNM;:_ EOH my @k = split/\n/,$k; # update: strings for diagonal mapping, e.g 1qa 2ws 3ed # the other diagonal is left as an exercise to the reader push @k, map { my $i=$_ ;join('',map{substr($k[$_],$_>3? $i+1:$i,1)} 0 +,2..4) } 0..11; push @k, map { my $i=$_ ;join('',map{substr($k[$_],$_>3? $i+1:$i,1)} 1 +..3,5) } 0..11; my @matches; chop (my $seq = <STDIN>); for my $i(0..length($seq) - 3) { my $t = substr($seq,$i,3); push @matches, /$t/ig for @k; } print "matches: @matches\n"; __END__ djuriops>yxcvatgb5 matches: iop >YX yxc YXC xcv XCV tgb tgB
--shmem
update: added diagonal match
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|