[kw-pm] Last night's meeting

Daniel R. Allen da at coder.com
Fri Jun 19 07:55:25 PDT 2009


...We had considered the ?:1 operator, on the board, but didn't see where
it got us. Clearly we didn't stare at it long enough.

But turning rand()<1/++$n into rand++$n<1 into rand$.<1 is sheer genius
on both of your parts. Nicely done, John and Raymond.

29 strokes == winner?

-Daniel

On Fri, 19 Jun 2009, Raymond wrote:

> >From the above:
>
>  $ perl -ne'rand++$n<1?$s=$_:1;END{print$s}' <alpha.html
>
> No need to increment a counter like $n, just use $. which gives the
> line number 1 indexed.
>
>  $ perl -ne'rand$.<1?$a=$_:1;END{print$a}' <alpha.html
>
> Also replaced $s with $a so it runs safe under 'warnings'. ;) Two more
> characters saved.



More information about the kw-pm mailing list