http://www.perlmonks.org?node_id=738099


in reply to Simulate a head lice infection

Looking at the following part of the code:

$min = int(rand(10)) + 15; $max = int(rand(25)); $dayofdeath = int(rand($max)) + $min;

You're first establishing a random maximum, and then taking a random value between zero and that first random number. This skews the day of death to lower values. I pulled this out and iterated it 2000 times and found the following number of deaths per day, starting from day 15:

44 53 66 106 116 127 128 134 145 173 133 104 90 76 67 69 55 56 50 41 30 26 21 29 24 8 13 8 5 1 2 1

This may be construed as a feature :)

The following block (and similar blocks):

print "DAY: $days\n"; print "================\n"; print "LICE: $n\n"; print "LIVE LICE: $living\n"; print "DEAD LICE: $deathtoll\n"; print "FEMALES: $females\n"; print "MALES: $males\n"; print "EGG LAYERS (FEMALE ADULTS): $egglayers\n"; print "NYMPHS (LITTLE/YOUNG): $toddlers\n"; print "EGGS: $eggsacks\n"; print "EGGS LAID TODAY: $eggslaidtoday\n"; print "================\n";

... can be written less noisily using a heredoc:

print <<END_OF_REPORT; DAY: $days ================ LICE: $n LIVE LICE: $living DEAD LICE: $deathtoll FEMALES: $females MALES: $males EGG LAYERS (FEMALE ADULTS): $egglayers NYMPHS (LITTLE/YOUNG): $toddlers EGGS: $eggsacks EGGS LAID TODAY: $eggslaidtoday ================ END_OF_REPORT

Off topic information on lice removal below the fold:

My own kids have caught lice at school on a couple of occasions, and I sympathise with you. We used a couple of nasty Agent Orange-like products to get rid of them, but the critters are developing resistance to them and thus they become less effective, and the doses stronger.

During the last infestation our pharmacist told us of a new product with is basically a liquid silicon gel, and as it dries out it suffocates the lice. In other words, a mechanical process rather than insecticidal, and thus nothing the bugs can evolve defenses against. And much less aggressive on a young child's scalp.

• another intruder with the mooring in the heart of the Perl