# keyboard sequence (qwertz), for request from germany my $k = <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 = ); 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