You did better than I did (_especially_ with optimizing sub a, and with getting rid of the Socket constants, which I knew was possible but didn't do), although you did miss a couple of opportunities...

We also both missed the argumentless-close trick that someone else pointed out, although I would have to test that one to be sure it doesn't close the socket also (or that doing so doesn't change the operation of the script). Can someone confirm which close statements need their arguments and, for that matter, whether it's possible to eliminate any of the close statements altogether without breaking something?

So I threw out my version and worked from yours update: again, and this is what I now have, weighing in at 508 bytes not counting line breaks (522 bytes with a full ASCII CRLF ending every line but the last, or 515 with Unix-style one-character newlines):

$/=$_;$(=shift;$a=shift;i(shift);socket S,2,1,6;bind S,a($a);listen S,5;while(@ARGV&&($_="$( $a f".shift)||accept(C,S)&&($_=<C>)&&close C){m!^(.*?) (.*?) ([e-i])([^/]*)./!s&&$(eq$1&&&$3($2,$4,$')}sub f{t($_ +,@_)for keys%k}sub a{pop=~/:/;pack'CxnC4x8',2,$',split'\.',$`}sub i{$k{$_[0]}= +1}sub g{t($_[0],$a,"e$_[1]",<F>)if open F,"<$_[1]";close F}sub h{t($_[0],$_, +'i')for keys%k}sub t{socket X,2,1,6;(connect X,a($w=shift))?print X"$( $_[0] $_[1]/$_[2]"and close X:$k{$w}=$7}sub e{open F,">$_[1]";print F $_[2];close F}

Note that this code is completely, utterly untested.


"In adjectives, with the addition of inflectional endings, a changeable long vowel (Qamets or Tsere) in an open, propretonic syllable will reduce to Vocal Shewa. This type of change occurs when the open, pretonic syllable of the masculine singular adjective becomes propretonic with the addition of inflectional endings."  — Pratico & Van Pelt, BBHG, p68

In reply to Re: P2P Golf: MoleSter by jonadab
in thread P2P Golf: MoleSter by hossman

Title:
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, details, 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, summary, 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.