Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: randfunc in Config

by Cow1337killr (Monk)
on Jun 28, 2016 at 04:32 UTC ( [id://1166716]=note: print w/replies, xml ) Need Help??


in reply to randfunc in Config

I don't think there is a foolproof method to check that Perl uses its own drand48 function.

It appears that $Config{randfunc} contains the name of the random function used to build the Perl version on your box.

Is there a way to lie to the poor Perl? Of course, there is. Just wave a twenty dollar bill in front of a hacker in a dark room. He will list half a dozen different ways to do it.

I scanned for drand48 in all the files in C:\Strawberry, the directory that holds my Strawberry Perl installation on my computer (with a Windows operating system). One of the files found was C:\Strawberry\perl\bin\perl524.dll. I am pretty sure that is the dll that gets run when I run perl from the command line. Maybe the "drand48" that it found in there is a decoy. I doubt it. (I just installed Strawberry Perl last week, by the way.)

Just to be clear, there is NO file in my C:\Strawberry directory with drand48 as part of the name.

With my limited knowledge of systems programming, that tells me that the executable code is embedded in C:\Strawberry\perl\bin\perl524.dll (that I mentioned above).

I have poked around and I can think of no easy way to get Perl or the operating system to reveal that Perl_drand48 is being called. (Obviously, an operating system dependent recipe is not desirable.)

Replies are listed 'Best First'.
Re^2: randfunc in Config
by Cow1337killr (Monk) on Jun 28, 2016 at 07:00 UTC

    This will give one an idea of the degree of confusion out in the field regarding this subject.

    I Googled "$Config{randfunc} drand48".

    I got three hits on this fellow's GitHub.

    The code below is from https://github.com/drzigman/perl-random/blob/master/drand48/driver_perl/generate.pl

    use Config; # Make sure we are using drand48 as the underlying implementation if($Config{randfunc} ne "drand48") { print "Perl is configured with randfunc '" . $Config{randfunc} . "' rather than drand48\n"; return 1; }

    This code won't work anymore.

    'Perl_drand48' is stored in $Config{randfunc}.

Re^2: randfunc in Config
by Cow1337killr (Monk) on Jun 29, 2016 at 03:58 UTC

    If someone asked me to change their Strawberry Perl installation so that it uses myrandom instead of Perl_drand48, I don’t know what I would do. I don’t know where I would go on the Internet to get an answer. However, if I did find a cookbook recipe and figured out how to do it, then there would be a 30% chance that I would forget to update $Config{randfunc} (which is the commonly accepted method of determining what program is ultimately called when you or I call rand() in a Perl program).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-03-29 01:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found