Dont even bother wasting your time reading over my node here. I was unaware that it had been done so many times before. Sorry! :(

OK, I was recently given this problem. Its not too hard, but its a fun little problem to figure out. The goal was to make a perl script that prints out a perl script, that prints out a perl script, and on and on. The trick was that it couldn't read itself in (so no using open(M,$0);). Well anyways, the following is the code I wrote to solve it:
$dna = '$dna = CAC;B%t = (C65C,"$dna",C66C,"\n",C67C,"C");Bfor($i=0;$i +<153;$i++)B{$q = ord(substr($dna,$i,1));Bif ($t{$q}) {print $t{$q};}B +else {print chr($q);}}'; %t = ('65',"$dna",'66',"\n",'67',"'"); for($i=0;$i<153;$i++) {$q = ord(substr($dna,$i,1)); if ($t{$q}) {print $t{$q};} else {print chr($q);}}
I know its not the greatest, but I like to hear other people's suggestions on how to make it shorter.

Replies are listed 'Best First'.
Re: Asexual Perl Code
by MeowChow (Vicar) on May 01, 2001 at 05:04 UTC
Re: Asexual Perl Code
by larsen (Parson) on May 01, 2001 at 05:03 UTC
    I think you could find interesting this thread.
      Bah. I hate when this happens. :(