in reply to Re: golf anyone? (taking first field)
in thread golf anyone? (taking first field)

If the colon begins the line, it should be the same as an empty line. That is, remove the '' from the output list.
  • Comment on Re: Re: golf anyone? (taking first field)

Replies are listed 'Best First'.
Re: Re: Re: golf anyone? (taking first field)
by blokhead (Monsignor) on Jan 07, 2003 at 07:32 UTC
    In that case,
    map{/([^:]*?)\s*(:|$)/;$1||()}@list;
    Back to 36 chars. ;)

    blokhead

      Yea, that's what I noticed when I decided to throw it out as a golf: stopping at the colon or the end-of-line complicates things in a slightly subtle manner. Doing it in multiple passes it's no big deal: chomp first, then delete the tail end stuff, then throw it away if empty. But that's not elegant, and it doesn't just "fit together" as a composition of functions (one feeding the result to the next outer one).

      I think this also has an interestingly high punctuation to alpha ratio.

      I see you make sure the pattern always matches, so $1 is always OK (just empty).

      —John