[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Obfuscated Perl AI (was Re: [FWP] a thought had while...)



On Tue, Jun 29, 1999 at 09:48:24PM -0400, Ronald J Kimball wrote:
> Well, here's a start.  I shortened it by 63 characters and squeezed it onto
> two lines. 
> while(<>){split;$w{'>'}.=" $_[0]";while(@_){$w{$_[0]}.=$".($#_?$_[1]:0);
> shift@_}$n='>';while($n){print"$n ";split' ',$w{$n};$n=$_[rand@_]}print$/}

Unk. You can tell I'm a C programmer in disguise. :)

I got it down one more character (moving the $n= def and using it twice):
while(<>){split;$n='>';$w{$n}.=" $_[0]";while(@_){$w{$_[0]}.=$".($#_?$_[1]:0);
shift@_}while($n){print"$n ";split' ',$w{$n};$n=$_[rand@_]}print$/}

You could also replace '>' with $$ if you didn't mind it printing the
PID of the process rather than > as the indicator. :)

But how come you can say 
	.=$".
for
	.=' '.
but not
	split$", 
for
	split' ',
(having tried both)?
~
I can also see other ways to do things which make it more obfuscated:

while(<>){split;$n='>';$w{$n}.=" $_[0]";while(@_){$w{$_[0]}.=$".($#_?$_[1]:0);
shift@_}while($n){print$n.$";$_=$w{$n};split;$n=$_[rand@_]}print$/}
 
-- 

Adam Sampson
azz@gnu.org

==== Want to unsubscribe from Fun With Perl?
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org