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?


In reply to Re: Using filepath method to identify an .html page by Anonymous Monk
in thread Using filepath method to identify an .html page by Nik

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.