Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

HOW to map both ways, in a one to one relation, (5-digit-integer <=> string) without losing any information?

CREATE TABLE pin_to_url ( pin int PRIMARY KEY, url varchar(255) ); SELECT v.*, pu.url FROM visitors v JOIN pin_to_url pu ON = ORDER BY whatever;

Just store the filename alongside the pin into the table and it'll work pretty well.

The only other way of mapping string to pin -- apart from the lookup table I've just typed out -- is enumerating over the possible filenames and hashing each in turn, comparing the result to the pin. There's no way around it with the constraints you stubbornly add.

Oh, by the way, with 100 files and 10k available (random-ish) identification numbers, you might hit the birthday paradox. About 60% probable, I think. You don't want a hashing function -- you want an integer sequence. Databases provide those.

In reply to Re^3: Converting a number back to it's original string (that was hashed to generate that number) by Anonymous Monk
in thread Reaped: Converting a number back to it's original string (that was hashed to generate that number) by NodeReaper

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2021-10-26 02:07 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (90 votes). Check out past polls.