Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Well, the actual code is:
$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}}}
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().

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

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [harishnv]: i have one doubt

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (5)
    As of 2018-02-18 11:26 GMT
    Find Nodes?
      Voting Booth?
      When it is dark outside I am happiest to see ...

      Results (253 votes). Check out past polls.