#!/usr/bin/perl -w use strict; srand(42); map { my $l = $_; my ($n, $r) = (0, int(rand(128))); print map { chr($r) if($l == ($n += $_)) } qw(100 43 6 159 12 4 28 96 15 72 2 72 158 338 275 34 60 155 327 38 153 18 119 271 212 57); } (1 .. 28 +25);
This code is not so much a pure obfu as it is a demonstration of why it is a Really Bad Idea to call srand with a known number (but you should have known that already).
Ok, here it is, the update you've all been waiting for: the version of this code that works under Windows! In completing this project I learned a very truth { view: change; !important } [1]: while the interface to rand is standardized across OS boundaries, the output for a given seed to srand is not. IMHO, output from rand for a given seed should be standardized in Perl 6. Well, without further ado, here is the code:
#!/usr/bin/perl -w use strict; srand(42); map { my $l = $_; my ($n, $r) = (0, int(rand(128))); print map { chr($r) if($l == ($n += $_)) } qw(253 170 79 20 166 414 240 374 123 32 149 95 56 64 128 185 7 72 316 323 40 67 216 8 17 19); } (1 .. +3635);
[1] Yes, I have way too much CSS running through my head... translating to english results in the phrase "view changing important truth".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why 42 is the answer to the ultimate question.
by Nkuvu (Priest) on May 12, 2005 at 22:08 UTC | |
by northwind (Hermit) on May 12, 2005 at 22:23 UTC | |
by northwind (Hermit) on May 12, 2005 at 22:14 UTC | |
|
Re: Why 42 is the answer to the ultimate question.
by northwind (Hermit) on May 12, 2005 at 22:07 UTC | |
|
Re: Why 42 is the answer to the ultimate question.
by TedPride (Priest) on May 13, 2005 at 01:37 UTC |