At 10:44 PM 5/4/00 +0100, Alistair.McGlinchy@marks-and-spencer.com wrote: >Nathan Torkington suggested > > perl -e'open A,shift;$h{$_}=1 while<A>;$h{$_}|=2 >while<>;map{print"\t"x($h{$_}-1),$_}sort keys%h' > > perl -e'$h{$_}|=2-@ARGV while<>;print"\t"x($h{$_}-1),$_ for sort keys%h' > > perl -ne'$h{$_}|=2-@ARGV;END{print"\t"x($h{$_}-1),$_ for sort keys%h}' > >As much as I like the techniques used here, Nathan's versions don't print >the same output as as Tim's. For eg, Nathan's doesn't deal with duplicate >entries in the one of the source files, nor does it print the output in the >same order as the input. > >I can't see how to use a hash and still preserve the correct order of both >input files. Here's my current best at 131. But it seems extremely beatable >with three "print"s and two "shift"s: > >perl -e'open B,pop;open A,pop;@a=<A>;while(<B>){print shift@a >while($a[0]lt$_&&$a[0]);$_=($a[0]eq$_)?"\t\t".shift@a:"\t$_";print}' Just shaving a bit off your score here down to 101, still playing the hole the same way: perl -e'open B,pop;@a=<>;while(<B>){print shift@a while $a[0]lt$_&&@a;print"\t",$a[0]eq$_?"\t".shift@a:$_}' -- Peter Scott Pacific Systems Design Technologies ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe