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

Re: Using filepath method to identify an .html page

by Anonymous Monk
on Jan 22, 2013 at 16:07 UTC ( [id://1014711]=note: print w/replies, xml ) Need Help??


in reply to Using filepath method to identify an .html page

Do I understand correctly that you've already got a database table with a column "pin" (I assume a unique integer?) and another column "page" which contains something like the URL of the page? Why not just use that unique identifier? (Or create another database table, as other people here have suggested?)

Anyways, although I don't think this is the correct solution for your situation, here is an answer to your original question: One concept of generating a number from a string is a Hash function, however, those numbers are generally not unique. Also, int has nothing to do with hash functions (the closest built-in is probably crypt, and that's not what you want, either).

The problem with your question is this: using a hash function causes you to lose information about the original string, and the numbers you generate won't be guaranteed to be unique anymore. If you want the numbers to be truly unique, then the only way to guarantee that is to keep a list of the original strings around, which you say you don't want to do because of the amount of data that means. Sorry, you can't have it both ways...

But maybe we're not quite understanding your existing set-up or what your goal is?

Replies are listed 'Best First'.
Re^2: Using filepath method to identify an .html page
by Nik (Initiate) on Jan 22, 2013 at 16:13 UTC
    Read this please, so to clarify what i need to do

    http://www.perlmonks.org/?node_id=1014708

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-03-28 22:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found