My script is separated into multiple packages. main.pl loads A.pm, which loads A::B.pm and A::C.pm. They all use rand. However, if I specify a seed for srand in main.pl, the latter modules seem to generate their own seed anyway. How can I seed the RNG only once and have the entire script predictable?
Call srand only once when loading perl modules
62 Views Asked by Anna At
1
There are 1 best solutions below
Related Questions in PERL
- Perl Regex for converting query strings
- Cross compiling perl for Android ld.lld: error: unable to find library -lpthread
- Regexp to remove small numbers and leave large ones
- `df` command not capturing entire output in perl
- Webmin CentOS7 AWS backup errors - perl(S3::AWSAuthConnection) can't be installed
- How to ignore perm errors with Path::Tiny 'visit'? (Windows)
- Why does setting `*\` to a scalar (string) reference not result in auto printing
- Regex for deconstructing SQL where statement
- Random characters in DS record from Net::DNS:RR when calling print/string
- Perl with Selenium: cannot save the Web page with Ctrl+S
- openssl pbkdf2 and perl
- Strawberry Perl using a separate winlibs distro
- Perl / Undefined value as a HASH reference when running SNMP queries
- Timestamp with timezone: works with isql but not with DBD::Firebird
- Slurping a file ... syntax error - example from perldoc
Related Questions in RANDOM
- Producing filtered random samples which can be replicated using the same seed
- Random getting value from a range or a specific value
- Unique and random selection of 10 rows per user in a table
- How to calculate the accuracy in number guessing game?
- Using attributes from instances of array of objects in other classes
- How do I write such a random source code generator?
- How to randomly load html file inside a html page on page load using javascript?
- New error on random number assigned to local variable , Rails
- Why does the code return the same 5 random numbers every time
- How can I efficiently find two numbers in an array that sum up to a given target without using the same element twice?
- How can I use a variable that is defined in one script in a different script in Unity
- Why is C# BigInteger not always the same bit length?
- Choosing a sequence of bitwise operations
- java: method nextLong in class java.util.Random cannot be applied to given types;
- How to add the outout the random element from array and keep adding 1 by 1 in empty array?
Related Questions in PERL-MODULE
- How can I optimize Symbolic Link Deletion in Perl?
- Can't load application from file /perl/school-reports/script/reports No such file or directory at /usr/local/share/perl/5.34.0/Mojo/Server.pm line 59
- Getting a symbol lookup error message when running a perl script: "...vxs.so: undefined symbol: Perl_xs_apiversion_bootcheck"
- How to install libdata-validate-ip-perl in centos
- When do Perl package variables fall out of scope?
- Export anonymous function from Package
- Uninitialized value when moving sorting function to package
- Math::Random::MT compilation failed
- How to split a list in two over a condition?
- Call srand only once when loading perl modules
- Trying to learn to install Perl module
- Assigning PWD last value to variable in perl module
- 500 Can't connect to localhost:443 (certificate verify failed)
- can't locate language.pm in centos
- ac.c: loadable library and perl binaries are mismatched (got handshake key 0000000012400080, needed 0000000012900080)
Related Questions in SRAND
- Mersenne vs Rand: Why do I get more total consecutive repetitions when using Mersenne compared to Rand? C++
- There seems to be a segmentation when trying to print 'Cselection' after reading 'Pselection' error andd I dont understand why
- Random Number Generator Cofirmation
- Why are my strings not printing in my story in c
- What techniques can I use to determine the number generated by srand() in C?
- srand/rand slowly changing starting value
- Using srand with pthread generate the same number in C
- creating function, outside main() function, for random Number in specific range
- C++ generate random numbers for a given seed
- How to generate randomize array and getting the third max of it
- How to store random number in usigned char variable in c++?
- Why do I get nearly the same number out of the rand() function in the first iteration?
- how to know the secret number from srand(time(0))
- Error in generating Random Character Arrays with Integer elements for Time Analysis of Insertion Sort Algorithm using rand() [ C++ ]
- I have problem with process in c code with argv parameters
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Put
srandin aBEGINblock inmain.pl, before loadingA:A complete example:
A.pm:B.pm:C.pm:main.pl:Running
perl -I . main.plalways print:If I put
srand(7)afteruse A, then the first three prints (fromA,BandC) are randoms, and only the one inmain.plis always the same.