On Thu, Mar 08, 2001 at 10:08:07AM -0500, Keith Calvert Ivey wrote: > I sent my shortened version to the creators of the code and got > this response. > > ------- Forwarded Message Follows ------- > To: "Keith Calvert Ivey" <kcivey@cpcug.org> > Cc: keithw@MIT.EDU > Subject: Re: Shortened qrpff.pl (503 bytes) > Date: Thu, 08 Mar 2001 05:24:17 -0500 > From: Keith Winstein <keithw@MIT.EDU> > > > We've had a little discussion on the Fun With Perl list, and > > this is my contribution. > > Hey, nice going. You had a few bugs in your code causing it to not quite > run without bombing out, but nothing too major. Thanks mostly to your > suggestions, here's where we are now (at 499 bytes): > > $_='$/=\2048;while(<STDIN>){k=29;c=142;if((@a=unx"C*",_)[20]&48){h=5;_= > unxb24,join"",@b=map{xB8,unxb8,chr(_^$a[--h+84])}@ARGV;s/...$/1$&/;d=unx > V,xb25,_;l=73;e=256|(ord$b[4])<<9|ord$b[3];d=d>>8^(f=(r=255)&(d>>12^d>>4 > ^d^d/8))<<17,e=e>>8^(r&(g=(q=e>>14&7^e)^q*8^q<<6))<<9,_=(map{_%16or+r^= > c^=(m=(11,10,116,100,11,122,20,100)[_/16%8])&110;r^=(72,@z=(64,72,k^=12 > *(_%16-2?0:m&17)),l^=_%64?12:0,@z)[_%8]}(16..271))[_]^((h>>=8)+=f+(~g&r > ))for@a[128..$#a]}print+x"C*",@a}';s/x/pack+/g;s/\b[c-r_]\b/\$$&/g;eval > > I couldn't seem to get current "Fun With Perl" archives, so hopefully > you can pass this on to the list. More suggestions are very > welcome. It would be great to get below 6 * 79 or 6 * 80 before it > goes on a T-shirt (although if we get within 5 and get stumped I'm > going to vote for killing the "STDIN" at the expense of some warnings > after it's reached the end of its input). If you don't mind slurping in all the data into memory, you can replace while(<STDIN>) by for(<STDIN>). If you don't mind warnings, you can replace the leading $_= with s' and save a byte. Furthermore, I think you can rename all your one letter lowercase variables to uppercase ones, from D to R, plus T. And then replace s/\b[c-r_]\b/\$$&/g by s/\b[D-RT_]/\$$&/g saving another byte. If you manage to use one variable less, even better. I don't how this program needs to be called; if there is only one argument, @ARGV can be replaced by 'pop', saving two bytes. If so, and you decide to get rid of STDIN, then the suggested substition to use in the case of upper case chars, can be reduced to: s/[D-S_]/\$$&/g (you can then savely use $S instead of $T, no conflicts). Also, since the thing basically a big loop over STDIN, you might get quite some gain by using perl -n, killing the entire need for the loop. Although the $/=\2048 might be a big obstacle. Do you count command line switches? If not, you can gain by using perl -s, and call the program with -k=29 -c=142, saving 11 bytes in the program body. (Of course, then any Perl program trivially reduces to 4 bytes: perl -s -e 'eval' -- -_='program text' ) Abigail ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe