Actually, bitwise-xor on strings and tr/// (update: see Quote-Like Operators in perlop) go together quite nicely for something like this:
c:\@Work\Perl\monks>perl -wMstrict -le "use Data::Dump qw(pp); ;; for my $word (qw(Fool Foot Tool Toot Foal)) { my $diff = 'Fool' ^ $word; print qq{'$word': }, pp $diff; print qq{'Fool' and '$word' differ by 1 char} if 1 == $diff =~ tr/\x00//c; } " 'Fool': "\0\0\0\0" 'Foot': "\0\0\0\30" 'Fool' and 'Foot' differ by 1 char 'Tool': "\22\0\0\0" 'Fool' and 'Tool' differ by 1 char 'Toot': "\22\0\0\30" 'Foal': "\0\0\16\0" 'Fool' and 'Foal' differ by 1 char
Update: Changed example code to use tr/\x00//c (/c modifier: complement the search list).
Give a man a fish: <%-{-{-{-<
In reply to Re^2: Comparing Lines within a Word List
by AnomalousMonk
in thread Comparing Lines within a Word List
by dominick_t
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |