Of course I'm not the one "Who wants to take the first crack at golfing this down" but giving a peek into the first few lines I notice that there's plenty of room for golfing. In fact I'm only a mediocre golfer, but golfers for example generally pop() rather than shift().$p=shift;$a=shift;i(shift);socket S,2,1,6;bind S,&a($a);listen S,5;$/=undef;while(@ARGV&&($_="$p $a f".shift)||accept(C,S)&&($_=<C>)& +&close C){m!^(.*?) (.*?) ([e-i])([^/]*)/!s&&$1 eq$p&&&$3($2,$4,$');}sub e{ope +n F,'>',$_[1];print F $_[2];close F}sub f{&s($_,@_)for keys %k}sub g{open(F,'<',$_[1])&&&s($_[0],$a,"e$_[1]",<F>);close F}sub h{&s($_[0],$_,'i')for keys %k}sub i{$k{$_[0]}=1}sub a{$_[0]=~/:/;pack'CxnC4x8',2,$',split'\.',$`}sub s{socket X,2,1,6;$w=shift;if(connect X,&a($w)){print X "$p $_[0] $_[1]/$_[2]";close X}else{undef $k{$p}}}
Or, for example, C<undef$/;> takes one keystroke less than C<$/=undef;>. But then (e.g.) C<$/=$_> will do and is even shorter.
Again, selecting a randomly picked line, I'm a big fan of the three-arguments form of open(), but C<open(F,'<',$_[1])> can be replaced by C<open F,pop>.
As a side note, since we're talking golf here, well one doesn't generally care much about good programming practices in this context. But the author of the original code's systematic (&-form of) calling of subs clearly tells what his programming skills can be...
In reply to Re: P2P Golf: MoleSter
by blazar
in thread P2P Golf: MoleSter
by hossman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |