This returns the common prefix length for two given strings. Except when it fails, that is. Which happens when NUL's are present in the (longer) string. A case that has actually bitten me before. The PHP semantics would be a win sometimes.sub ncp { ($_[0] ^ $_[1]) =~ m/\0*/; $+[0]; }
In reply to Re^2: port a function from php
by oiskuu
in thread port a function from php
by reqnode
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |