Don't Panic.

I thought this was fitting with the Hitchhikers Guide to The Galaxy out in theaters now.  Windows variant available under read more.

#!/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
    Nice JAPH on a Un*x box, on a Win2k machine it only produces "↕♥\>h)c["aF#W1♣{ls[/I=rl⌂-" (a.k.a. gobbledygook)

      Ironically, your comment could be taken as further proof that the Windows enviroment is not a part of the solution to the ultimate question...  :P

      Bring on the OS holy wars!

      Thank you for your feedback!  I will see what I can do to get it working under Win2K.
      Update: It now works under Windows.

Re: Why 42 is the answer to the ultimate question.
by northwind (Hermit) on May 12, 2005 at 22:07 UTC

    After seeing the reputation for this node fluctuate in the single digits, I am wondering why people are up/downvoting it without giving constructive criticism.  Please help me out here and leave a bit of feedback.  Thanks  :)

Re: Why 42 is the answer to the ultimate question.
by TedPride (Priest) on May 13, 2005 at 01:37 UTC
    That movie is crud. The original BBC black and white production was more fun to watch. I will admit that their Zaphod Beeblebrox was worlds better than BBC's, but the rest of the characters, with the exception of Arthur Dent, were totally flat and boring and miscasted. And the editing was horrible! They made half the movie drag on longer than it should, and they cut out much of the interesting material from the book - like Ford Prefect talking the guy in charge of the bulldozers to take over for Arthur Dent by lying down in front of the bulldozers in the mud.

    Basically, there's enough funny material in the movie to make it entertaining if you've never read the book or watched the BBC production. Otherwise, forget it.