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

Nik has asked for the wisdom of the Perl Monks concerning the following question:

What i want to do, is to associate a number to an html page's absolute path for to be able to use that number for my database relations instead of the BIG absolute path string.

so to get an integer out of a string i would just have to type:

htmlpage = a string respresenting the absolute path of the requested .html file
# =========================================================== # produce a hash string based on html page's filepath and convert it t +o an integer, that will then be used to identify the page itself # =========================================================== pin = int( htmlpage )
But would that be unique?



Here is some background information:

This counter script will work on a shared hosting enviroment, so absolutes paths are BIG and expected like this:



/home/nikos/public_html/varsa.gr/articles/html/files/index.html

In addition to that my counter.py script maintains details in a database table that stores information for each and every webpage requested.

My 'visitors' database has 2 tables:

pin --- page ---- hits (that's to store general information for al +l html pages) <br><br> pin <-refers to-> page <br><br> pin ---- host ---- hits ---- useros ---- browser ---- date (that's t +o store detailed information for all html pages) <br><br> (thousands of records to hold every page's information) <br><br>
'pin' has to be a number because if i used the column 'page' instead, just imagine the database's capacity withholding detailed information for each and every .html requested by visitors!!!

So i really - really need to associate a (4-digit integer <=> htmlpage's absolute path)

Maybe it can be done by creating a MySQL association between the two columns, but i dont know how such a thing can be done(if it can).

So, that why i need to get a "unique" number out of a string. please help.