in reply to Re: Tell whether two strings differ at only one position
in thread Tell whether two strings differ at only one position
While I liked each and every solution other wise monks have been so kind to come up with so far, when I looked at the solution of japhy, I immediately saw that this is the one I have been searching for! It is clean and concise and perlish, and, quite amazingly, it is just one statement, so I can eliminate the compare sub alltogether which, as I hope, will make my script even faster!sub compare { (($_[0] ^ $_[1]) =~ tr/\0//c) < 2; }
I am beginning to see that after a certain point, Perl programming becomes a matter of pure aesthetics...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Tell whether two strings differ at only one position
by ikegami (Patriarch) on Aug 04, 2005 at 21:16 UTC | |
by rg0now (Chaplain) on Aug 05, 2005 at 09:59 UTC |