[pacman-dev] [PATCH 2/3] pacsearch with repo-agnostic coloring

Allan McRae allan at archlinux.org
Wed Jan 15 19:13:18 EST 2014


On 16/01/14 02:03, Martti Kühne wrote:
> On Wed, Jan 15, 2014 at 9:50 AM, Allan McRae <allan at archlinux.org> wrote:
> [...]
>>
>>> +     # hash function (x*2+1) is completely arbitrary.
>>> +     my $repohash = $v[0];
>>> +     $repohash =~ s/(.)/ord($1)*2+1/ge;
>>
>> I have very little perl knowledge, so I have no idea what that hash is
>> doing.  Can someone explain to me so I can see if that "hash" is reasonable.
>>
> 
> Replace each character with its [0] ascii index times two plus one?
> 'g' is group regexes, 'e' is eval expressions [1], as to utilize the
> result of the calculation.
> 
> cheers!
> mar77i
> 
> [0] http://perldoc.perl.org/functions/ord.html
> [1] http://stackoverflow.com/questions/6082219/perl-regex-e-eval-modifier-with-s
> 

Does that mean the answer can only be odd?

Allan



More information about the pacman-dev mailing list