Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

by Anonymous Monk
on Jan 23, 2013 at 11:00 UTC ( #1014877=note: print w/ replies, xml ) Need Help??


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

The OP seems a bit unwilling to listen, but if you truncate the hash, you meet his spec.

use Digest::MD5 qw/ md5_hex /; my $digest=md5_hex("http://www.berghold.net"); printf "%d\n", hex(substr($digest, -4)) % 10_000;

So the one-liner he's looking for would be hex(substr(md5_hex($someurl), -4)) % 10_000. I'm betting that is somewhat collision resistant. The OP still should consider enlarging his int2 column to int4 or int8 or even char(4)


Comment on Re^2: Using filepath method to identify an .html page
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1014877]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2015-07-07 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls