...hmmm... and now we may have an argument for using microtime...

If you've moved away from staying pure Perl, for a source of an unguessable counter, I'd use the Time Stamp Counter.

Given that this changes by anything ranging from 1/2 a million to 10s of millions between successive calls in a tight loop, the odds of collisions even if you have 16 concurrent cores are negligible:

#! perl -slw use strict; use Inline C => Config => BUILD_NOISY => 1; use Inline C => <<'END_C', NAME => 'rdtsc', CLEAN_AFTER_BUILD => 0; SV *rdtsc() { return newSVuv( (UV)__rdtsc() ); } END_C my( $last, $this ) = ( 0, 0 ); print( $this = rdtsc(), ' ', $this - $last ), $last = $this for 1 .. +20; __END__ C:\test>rdtsc 95054001389914 95054001389914 95054002276396 886482 95054003052862 776466 95054004698944 1646082 95054006658865 1959921 95054008588537 1929672 95054010420586 1832049 95054012410180 1989594 95054014268572 1858392 95054016253981 1985409 95054018070946 1816965 95054050803874 32732928 95054051382070 578196 95054053061884 1679814 95054054901610 1839726 95054056870252 1968642 95054058682825 1812573 95054060659909 1977084 95054062399501 1739592 95054064304702 1905201

Indeed, used alone with some suitable modulus operations, it would form the basis of a pretty damn good cryptographic rand() all by itself.

Even if the bad guys had an identical system -- hardware and software -- it would be impossible to predict the next number coming from it. It is affected by every single thing that happens on the system -- interrupts from your nic; mouse movements; thermal loading; every piece of software running in the systems.

Even if you put two totally identical systems side by side and synchronised them, I bet they would not stay in step for more than a few milliseconds.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?


In reply to Re^3: How do I get a unique Perl Interpreter ID? by BrowserUk
in thread How do I get a unique Perl Interpreter ID? by wrog

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.