Turning number ranges into prefixes
Nicholas Clark
nick at ccl4.org
Wed Aug 23 21:59:46 BST 2006
On Wed, Aug 23, 2006 at 05:21:31PM +0100, Simon Cozens wrote:
> David Cantrell:
> > $ perl -e 'print "1424210000" ^ "1424225999"'
> > [some whitespace]
>
> Sorry, there was some magic I was missing; I half-remembered this hack, which
> I think is either due to Nicholas or Damian. Given
> ($a ^ $b) =~ /^(\0+)/,
> the common prefix between $a and $b is
> substr($a, 0, length($1)).
It certainly wasn't me. I believe it wasn't Damian himself, but the
association with Damian is that he presented it in one of his talks,
crediting the evil genius actually behind it.
It's definitely a nice trick.
Nicholas Clark
More information about the london.pm
mailing list