|
|
| Perl: the Markov chain saw | |
| PerlMonks |
Re: Fast Identification Of String Differenceby AnomalousMonk (Prior) |
| on Jan 17, 2011 at 03:31 UTC ( #882593=note: print w/ replies, xml ) | Need Help?? |
|
The 'classic' Perlish approach to this type of problem involves bitwise string boolean operations. The string $diff generated by the bitwise-xor of characters in original sequence strings can be used to produce masks that can then be used to extract the differing sub-string sequences from the original strings.
Output:
See @- and @+ in perlvar, also Bitwise Or and Exclusive Or and Bitwise And in perlop. BrowserUk is very good on this general topic. Update: Added better code example, doc links. And thanks to ELISHEVA. Update: Fixed @- link above. What was I thinking?
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||