[comp.lang.perl] Transcendental Meditations

rbj@uunet.UU.NET (Root Boy Jim) (03/15/91)

In article <1991Mar14.225605.29822@iwarp.intel.com> merlyn@iwarp.intel.com (Randal L. Schwartz) writes:

># note the number of dots in each (..) below...
>print reverse"er,k haclr Perst anotheJu"=~/(...)(.)(....)(.)(.....)(.........)(..)/

We can expand on this:	(note: ~ stands for previous line)

first, we have to generate pi/4:	atan2(1,1)
then, get the proper number of digits:	int(~*4000000)
next, split it into chars:		split('',~)
now build each (...):			grep($_ = '(' . ('.' x $_) .')',~)
now join it back together:		join('',~)

It gets a bit tricky here. Because m// has no e flag (Larry?),
I have to build and eval the match expression.
I already have a join open, so I'll just glom onto that.
The whole thing then becomes (split for clarity):

		print reverse eval  
		join('','"er,k haclr Perst anotheJu"=~/',
		grep($_='('.'.'x$_.')', 
		split('',int(atan2(1,1)*4000000))),'/') 

Then, of course, you can further obfuscate the constant 1,
by replacing with exp(0), cos(0), or even __LINE__.
-- 
		[rbj@uunet 1] stty sane
		unknown mode: sane