in reply to Remove a common prefix from two strings
Two thingsno warnings 'regexp'; ($str0 ^ $str1) =~ /^((??{chr(0)})*)/; $commonLen = $+[0];
should suffice and it shouldn't even be necessary to initialize $commonLen to zero:($str0 ^ $str1) =~ /^\0*)/;
#!/usr/bin/perl -l use strict; use warnings; sub clen { ($_[0] ^ $_[1]) =~ /^\0*/; $+[0]; } print +(clen split) while <DATA>; __END__ aaaa bbbb aaaa abbb aaaa aabb aaaa aaab aaaa aaaa
|
|---|