Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Re: Re: 3-D Stereogram, Self replicating source.

by Toodles (Monk)
on Oct 16, 2001 at 11:52 UTC ( #119081=note: print w/replies, xml ) Need Help??

in reply to Re: Re: 3-D Stereogram, Self replicating source.
in thread 3-D Stereogram, Self replicating source.

Your analysis is entirely correct, with the exception of the tr/// oversight someone else already pointed out. If anyone wants to see the de-mangling of the string, start up the perl debugger
perl -d
and 'W'atch $_
W $_
and step by step down towards the eval with the 'n' command. It should be obvious as soon as you see the line of Q's. Next it removes everything from the Q's to end of line. You'll be left with:
my(@f,@c,@w);@a=@f=<DATA>;seek(DATA,0,0);@c=<DATA>; until(($_=pop(@c))=~/^_/){};unshift(@a,$_);for(1..3) {print(shift(@c));}for(@f){my($s);split//; $_=shift(@c);$_=~s/(.{15}).*/\1/;@w=split//;for(@_) {$w[$s+15-$_]=(($w[$s]eq",")?".":$w[$s]);$s++;} for(1..75){unless($w[$_]ne''){$w[$_]=$w[($_-1)];}} print(join"",@w);print"\n";}print@a;
With decent space, comments, and more meaningfull variable names...This is for education only; wont work unless in proper shape, with DATA available.
my(@f,@c,@w); @a=@f=<DATA>; #Read everything from __DATA__ onward into #array @f and @a seek(DATA,0,0); #Seek to begin of source file @c=<DATA>; #Read it all into @c , #!, DATA, and all until( ($_=pop(@c)) =~ /^_/ ){}; #This removes one line at a time from the end # of the source copy in @c, until the line # removed begins with an underscore (i.e. __DATA__ #Now, all that remains in @c is the actuall code; #all __DATA__ and the __DATA__ marker itself have #been removed. unshift(@a,$_); # $_, which still contains the string "__DATA__" we #removed from @c, gets placed at the beginning of @a. We # now have @c, which contains everything in the file up to # the last eval line, @a, which contains the "__DATA__" line # and all of the DATA, and @f which contains just the DATA # contents for(1..3){ #Just do this three times print(shift(@c)); #pop of the top three lines of source and #print them. e.g., "#!/usr/bin/perl", copyright notice, and } # the four hashmarks to align your eyes. for(@f){ # once for each line of DATA my($s); #Remember, 'my' will undef the scalar out everytime # this is reached. Could just as easily be $s=0; split//;#Split it up into an array byte-by-byte. If the #string was "1234", @_ would equal ('1', '2', '3', '4' +) $_=shift(@c); #Grab the next line of code.... $_=~s/(.{15}).*/\1/; #Chop off everything after 15 charachters +. @w=split//; #Split up those 15 charachters into a 15 element a +rray #and put into @w for(@_) # For each letter of the current line pulled from DATA +... {$w[$s+15-$_]=(($w[$s]eq",")?".":$w[$s]); #Err, thats a big one. Remember, the closer the the vi +ewer #you want that character to be, the closer together th +e #charachters that make up that plotted character have +to #be. Also, I am trapping ','s here, because if one fin +ds #its way into the jumble, it'll throw off the quoting +and #ruin the script. Most people won't notice the differe +nce #between the two when staring unless they know to look +. I #would have preffered to use 'ell' and 'one', but cant + use #them as quoting characters. $s++; #and go down the line one by one. } for(1..75){ #the images are 75 charachters wide. For each one. +.. unless($w[$_]ne'') { #If no charachter was put there.. +. $w[$_]=$w[($_-1)]; #put in a copy of the one t +o #the left } } print(join"",@w); # Print out our line we just made. print"\n"; #goto next line, Lather, rinse, repeat. } print@a; #Finally, print the __DATA__ label, and original DATA content +s
Things I should have done differently: The first my(...) was totally unneeded. I didn't use strict or -w, so this should have gone out the window. I should have used if instead of unless where possible. 4 wasted charachters each. $s-=$s or $s^=$s would have been more fun than my($s) and done the same thing Since the charachters in the DATA section get added in a numeric scalar context, that means that anything not a digit equates to 0. So, instead of bunches of 0's, I could do anything, even making harder to read the data some like this smiley: Feel free to try it.
__DATA__ llllllllllllllllllllllllllllllllllllllllllllllllllllllllllll llllllllllllllllllllllllllllllllllllllllllllllllllllllllllll llllllllllllllllllllllllllllllllllllllllllllllllllllllllllll llllllllllllllllllllllll1111111lllllllllllllllllllllllllllll lllllllllllllllllll111111111111111111lllllllllllllllllllllll lllllllllllllllll1111111111111111111111lllllllllllllllllllll lllllllllllllll11111ll111111111111ll11111lllllllllllllllllll llllllllllllll111111ll111111111111ll111111llllllllllllllllll lllllllllllll1111111ll111111111111ll1111111lllllllllllllllll llllllllllll11111111ll111111111111ll11111111llllllllllllllll llllllllllll11111111ll111111111111ll11111111llllllllllllllll lllllllllll111111111ll111111111111ll111111111lllllllllllllll lllllllllll1111111111111111111111111111111111lllllllllllllll llllllllll1111l11111111111111111111111111l1111llllllllllllll lllllllllll111ll111111111111111111111111ll111lllllllllllllll lllllllllll1111ll1111111111111111111111ll1111lllllllllllllll llllllllllll1111ll11111111111111111111ll1111llllllllllllllll llllllllllll11111lll1111111111111111lll11111llllllllllllllll lllllllllllll11111lllll1111111111lllll11111lllllllllllllllll llllllllllllll111111llllllllllllllll111111llllllllllllllllll lllllllllllllll11111111llllllllll11111111lllllllllllllllllll lllllllllllllllll1111111111111111111111lllllllllllllllllllll lllllllllllllllllll111111111111111111lllllllllllllllllllllll llllllllllllllllllllllll1111111lllllllllllllllllllllllllllll llllllllllllllllllllllllllllllllllllllllllllllllllllllllllll llllllllllllllllllllllllllllllllllllllllllllllllllllllllllll llllllllllllllllllllllllllllllllllllllllllllllllllllllllllll

Edit: chipmunk 2001-11-12

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://119081]
and snow settles gently...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2018-04-22 01:31 GMT
Find Nodes?
    Voting Booth?