Turning number ranges into prefixes

Simon Cozens simon at simon-cozens.org
Wed Aug 23 17:21:31 BST 2006


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)).

-- 
Life would be so much easier if we could just look at the source code.
	-- Dave Olson


More information about the london.pm mailing list