Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re^5: Using filepath method to identify an .html page

by blue_cowdawg (Monsignor)
on Jan 22, 2013 at 19:34 UTC ( #1014774=note: print w/replies, xml ) Need Help??

in reply to Re^4: Using filepath method to identify an .html page
in thread Using filepath method to identify an .html page

      The perl code will produce the same hash for "abc.html" as for "bca.html"

Which underscores the point I made earlier about adding collision detection and rehashing logic to whatever algorithm you use. One workround I've seen:

| handwaving here... my @i = split(//,$url); # put each letter in it's own bin my $j=0; # Initailize our my $k=1; # hashing increment values my @m=(); # workspace foreach my $n(@i){ my $q=ord($n); # ASCII for character $k += $j; # Increment our hash offset $q += $k; # add our "old" value $j = $k; # store that. push @m,$q; # save the offsetted value } my $hashval=0; #initialize our hash value # Generate that map { $hashval = ($hashval + $_) % 10000} @m;
Using that method ABC.html and CBA.html now have different values because each letter position's value gets bumped up increasingly from left to right.

Peter L. Berghold -- Unix Professional
Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1014774]
[oakbox]: Anyone else having difficulty looking at
[oakbox]: I keep getting a proxy error.
[marto]: try http://metacpan. org/
[marto]: I can't access search.cpan right now either. I prefer the metacpan search and general formatting anyway. Also it seems faster
[oakbox]: Yeah, the front page of uses now for search results
[oakbox]: but there are a billion links 'out there' linking to
[marto]: yep :)
[Discipulus]: being her marto, can you explain what "Par for the course I'm afraid." means?

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2017-07-26 10:10 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (388 votes). Check out past polls.