DreamT has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
br> I have a task where i'm supposed to send a certain percentage of the users to one location, and the rest to another location.
I have an idea where I want to use the session key and modulus, but I don't know how to implement it. Some pseudocode:
br> I have a task where i'm supposed to send a certain percentage of the users to one location, and the rest to another location.
I have an idea where I want to use the session key and modulus, but I don't know how to implement it. Some pseudocode:
As you can see I'm quite clueless on this, but it's more of a mathematical problem than a code problem. I know that I need to do some calculations on the string before I can use modulus on it, but how?# 1. Convert every character to a number using ord? # 2. ??? # 3. use modulus 100 on the converted string to get 1 or 0 if (($converted_string % 100) < $percentage) { $location = "new location"; } else { $location = "old location"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Send x% of the users to A, the rest to B
by BrowserUk (Patriarch) on Oct 26, 2012 at 10:58 UTC | |
by Perleone (Initiate) on Oct 27, 2012 at 20:04 UTC | |
by BrowserUk (Patriarch) on Oct 27, 2012 at 21:02 UTC | |
Re: Send x% of the users to A, the rest to B
by choroba (Cardinal) on Oct 26, 2012 at 10:24 UTC | |
by DreamT (Pilgrim) on Oct 26, 2012 at 11:47 UTC | |
by Laurent_R (Canon) on Oct 27, 2012 at 08:58 UTC | |
by ltp (Beadle) on Oct 28, 2012 at 11:30 UTC | |
Re: Send x% of the users to A, the rest to B
by talexb (Chancellor) on Oct 26, 2012 at 19:43 UTC | |
Re: Send x% of the users to A, the rest to B
by Anonymous Monk on Oct 26, 2012 at 12:43 UTC |
Back to
Seekers of Perl Wisdom