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

RE: [FWP] comm Golf




> -----Original Message-----
> From: owner-fwp@technofile.org [mailto:owner-fwp@technofile.org]On
> Behalf Of tayers@bridge.com
> Sent: Thursday, May 04, 2000 11:12 AM
> To: fwp@technofile.org
> Subject: [FWP] comm Golf
> 
> 
> I've enjoyed grok'ing the Golf shots lately. Wanting to practice a
> little I pulled out my Llama book and tried some of the
> exercises. Several were fun for me, but too easy for this group so
> last night I tried implementing the UNIX 'comm' command 
> without options.
> 
> The best I came up with was
> 
> perl -e'open A,$ARGV[0];open B,$ARGV[1];$a=<A>;$b=<B>;($a ne$b?$a 
> lt$b?($_=$a,$a=<A>):($_="\t$b",$b=<B>):($_="\t\t$a",$a=<A>,$b=
> <B>),print)while$a&&$b;print$a,<A>,$\="\t",$b,<B>'

I am not gonna spend too much time on this, but there are some obvious
improvements:

	You can change $ARGV[0] and $ARGV[1] to shift.
	You can change && to & in the while() conditional.

This is an improvement of 7 right there.

--Ala

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe