Grokbase Groups Perl ai August 2001
FAQ

On 27 Aug 01 at 11:40:36AM, Ala Qumsieh wrote:

Hey all,

I hacked a very quick Perl/Tk version of Conway's Game of Life and thought
some of you might enjoy it.

--Ala

Interesting coincidence. I've just been working on a perl version of
"life" myself.

It's not Tk and it's not quite as easily customised. But it's
obfuscated, and hopefully amusing. I was going to post it to clpm, but
why miss an opportunity like this to post it here?

Regards,


Ian



--------------------
#!/usr/bin/perl -w

$u =
" \n".
" \n".
" \n".
" \n".
" \n".
" \n".
" \n".
" o o o ooo ooooo ooo o o ooo ooooo o o ooooo ooo \n".
" o o o o o o o oo o o o o o o o o o \n".
" o o o ooo o ooooo o o o o o o ooooo ooo ooo \n".
" o o o o o o o o o oo o o o o o o o o \n".
" ooo ooo ooo o o o o o ooo o o o ooooo o o \n".
" \n".
" \n".
" o o ooooo ooooo o o ooo ooo o o ooooo oooo \n".
" o o o o o o o o o o o o o o o \n".
" o o ooo ooo ooooo ooooo o oo ooo oooo \n".
" o o o o o o o o o o o o o o o \n".
" ooooo o o ooooo o o o o ooo o o ooooo o o \n".
" \n".
" \n".
" \n".
" \n".
" \n".
" \n".
" \n".

"\n";

$w = index $u, "\n";

%genes = (
"CA" => "(?<=(.)[\\w\\W]{" . ($w+1) . "})",
"A" => "(?<=(.)[\\w\\W]{" . ($w) . "})",
"GA" => "(?<=(.)[\\w\\W]{" . ($w-1) . "})",
"C" => "(?<=(.))",
"G" => "(?=(.))",
"TC" => "(?=[\\w\\W]{" . ($w-1) . "}(.))",
"T" => "(?=[\\w\\W]{" . ($w) . "}(.))",
"TG" => "(?=[\\w\\W]{" . ($w+1) . "}(.))",
);

($dna = "CAAGAC.GTCTTG|CAAGAC.G|C.GTCTTG|CAAC.TCT|AGA.GTTG|CAAC.|AGA.G|C.TCT|.GTTG")
=~ s/CA|GA|A|TC|TG|T|A|C|G|T/$genes{$&}/g;

sub evolve
{
my ($n);
$n += (defined($$_) and $$_ eq "o")? 1: 0 for (1 .. 42);
return (($n == 2 and $& eq "o") or $n == 3)? "o": " ";
}

print($u), $u =~ s/$dna/evolve/ego while("universe exists");

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 6 | next ›
Discussion Overview
groupai @
categoriesperl
postedAug 27, '01 at 3:41p
activeAug 29, '01 at 2:03a
posts6
users4
websiteperl.org

People

Translate

site design / logo © 2021 Grokbase