Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^3: Late PM, 12/24/2014 & all year long

by BrowserUk (Patriarch)
on Dec 30, 2014 at 00:40 UTC ( [id://1111657]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Late PM, 12/24/2014 & all year long
in thread Late PM, 12/24/2014 & all year long

Suggestion: When posting code that uses rand, intended for cross-platform consumption & reproducibility: use Math::Random::MT qw[ rand srand ];.


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.

Replies are listed 'Best First'.
Re^4: Late PM, 12/24/2014 & all year long
by ww (Archbishop) on Dec 30, 2014 at 03:13 UTC

      Uh ... sorry to be a wet blanket, but it doesn’t help on my system (Strawberry Perl, Windows 8.1, 64-bit):

      19:01 >perl -e "srand 42; print sort {4-rand 9} split //, 'ts aroMrhir +sae C tll!!ym';" l ttyaMeos arrCsrihm!!l 19:01 >perl -e "use Math::Random::Mt qw[rand srand]; srand 42; print s +ort {4-rand 9} split //, 'ts aroMrhirsae C tll!!ym';" l ttyaMeos arrCsrihm!!l 19:01 >perl -v This is perl 5, version 20, subversion 0 (v5.20.0) built for MSWin32-x +64-multi-thread

      :-(

      Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

        . sorry to be a wet blanket, but it doesn’t help on my system (Strawberry Perl, Windows 8.1, 64-bit):

        Of course not. It would need to have been used by the author when constructing the obfu.


        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.
        l ttyaMeos arrCsrihm!!l

        With my perls, the original one-liner works as intended for 5.8.8 up to and including 5.18.0.
        But with 5.20.0 I get the same as you.

        The srand documentation contains this:
        However, there are a few situations where programs are likely to want to call "srand". One is for generating predictable results, generally for testing or debugging. There, you use "srand($seed)", with the same $seed each time.
        That suggests to me that srand(42) should produce identical results whenever it is called.
        I can't find anything in the docs that indicate there have been changes to srand - grepping 5.20.0 perldelta for srand produced no hits.

        However, there *is* mention (in perldelta) of changes to rand with 5.20, and I guess that if the rand implementation has changed then the same seed will no longer yield same results.
        I do think that the breakage of srand($seed) between 5.20 and earlier perls should have been spelled out in the srand documentation ... probably worth a bug report from someone who cares.

        Cheers,
        Rob

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-16 04:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found