Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.85k stars 527 forks source link

C:\WINDOWS\TEMP\bugrep0-34706349 #73

Closed p5pRT closed 20 years ago

p5pRT commented 24 years ago

Migrated from rt.perl.org#875 (status was 'resolved')

Searchable as RT875$

p5pRT commented 24 years ago

From MCVAYRA@mail.northgrum.com

The rand() function should produce a specific\, repeatable sequence of number given some specific seed value passed to srand(). I have found that all the Unix ports of Perl\, versions 5.004 and 5.005\, do behave in this manner but the Intel ports do not. Using the simple program

  srand('028350);   print rand()\, "\n";

from the command line the following results were obtained.

======== Win95 perl -e "srand('028350');print rand();" 0.826446533203125 perl -v This is perl\, version 5.005_03 built for MSWin32-x86-object

perl -e "srand('028350');print rand();" 0.6142578125 This is perl\, version 5.004_02

======== Linux (Intel) perl -e 'srand("028350");print rand()\,"\n";' 0.0450114482082427 perl -v This is perl\, version 5.005_03 built for i686-linux

======== AIX perl -e 'srand("028350");print rand()\,"\n";' 0.053741455078125 perl -v This is perl\, version 5.004_01

perl -e 'srand("028350"); print rand()\,"\n";' 0.053741455078125 perl -v This is perl\, version 5.005_02 built for aix

======== DEC Unix perl -e 'srand("028350");print rand()\,"\n";' 0.053741455078125 perl -v This is perl\, version 5.004_01

======== HPUX perl -e 'srand("028350");print rand()\,"\n";' 0.053741455078125 perl -v This is perl\, version 5.004_01

Perl Info ``` Site configuration information for perl 5.00503: Summary of my perl5 (5.0 patchlevel 5 subversion 03) configuration: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x86-object uname='' hint=recommended, useposix=true, d_sigaction=undef usethreads=undef useperlio=undef d_sfio=undef Compiler: cc='cl.exe', optimize='-Od -MD -DNDEBUG -TP -GX', gccversion= cppflags='-DWIN32' ccflags ='-Od -MD -DNDEBUG -TP -GX -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_OBJECT' stdchar='char', d_stdstdio=define, usevfork=false intsize=4, longsize=4, ptrsize=4, doublesize=8 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10 alignbytes=8, usemymalloc=n, prototype=define Linker and Libraries: ld='link', ldflags ='-nologo -nodefaultlib -release -machine:x86' libpth="D:\usr\lib\core" libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib PerlCRT.lib libc=D:\usr\lib\core\PerlCRT.lib, so=dll, useshrplib=yes, libperl=perlcore.lib Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -release -machine:x86' Locally applied patches: ACTIVEPERL_LOCAL_PATCHES_ENTRY @INC for perl 5.00503: D:/usr/lib D:/usr/site/lib . Environment for perl 5.00503: HOME=D:\WinCVS LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=E:\VISUALCAFE\JAVA\BIN;D:\WINCVS;D:\USR\BIN;C:\NOVELL\CLIENT32;C:\WINDO WS;C:\WINDOWS\COMMAND;D:\BIN;C:\PROGRA~1\COMMON~1\POWERS~1;D:\TCL\BIN;D:\ORA WIN\BIN;D:\ORAWIN95\BIN;D:\QUANTUM;C:\LANCD;E:\IMNNQ_95 PERL_BADLANG (unset) SHELL (unset) ```
p5pRT commented 20 years ago

From The RT System itself

comparing unix ports and intel ports is weird. Probably means win32 and unix.

p5pRT commented 20 years ago

From [Unknown Contact. See original ticket]

different platforms may use different rand() functions.

As long as the sequence generated by​:

srand( 10 ); for (1..3) { print rand(); }

is consistent between multiple runs on one platform\, this isn't a bug.

Obviously - the above snippet should be extendable to any srand value or any length sequence.

The idea _is_ to generate a random number\, not something that can be specified.