Whoops, I dropped the opening brace from my de-golf'ing. I'll correct that above, but also try to explain it a little more explicitly.

The thing to remember is that the perldoc perlrun entry for -n is applied literally.

Again from perldoc:

while (<>) { ... # your program goes here }

So -n literally puts that code around yours.

while(<>){ / /, $;{$`}++}{print $_, $/ ^= "*" for % # this line is what # was inside the single qu +otes }

Literally. The }{ closes the while loop and lets you add extra code outside the while loop. And since -n will always add that extra closing brace, you need to open one. Resulting in:

while(<>){ / /, $;{$`}++ } { print $_, $/ ^= "*" for % }


--chargrill
s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)

In reply to Re^7: parsing output of UNIX `who` command (golf) by chargrill
in thread parsing output of UNIX `who` command by chinamox

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.