On Jan 8, Yitzchak Scott-Thoennes said:

>I prefer (at least sometimes) to see golf worked out interactively, on
>the list.

I'm not sure I understand.  Shall I show my code?

>A file has 0 or more fields on each line.
>Fields are separated by 1 or more whitespace characters.
>Leading and trailing whitespace should be ignored.
>Comments (starting with # and continuing to the end of the line) should
>be ignored.
>A field may have surrounding double-quotes.  Such a field may contain # or
>whitespace (but not ").  The surrounding quotes are themselves not part of
>the field.  Any other use of a " has no special meaning (e.g.:
>howdy, "partner# foo
>is a line with two fields, 'howdy,' and '"partner').
>
>Read the file and print the fields of each line separated by ':'.

My code is below.





























More below.












  # 57
  $\=$/;$,=':';print/("[^"]*"|[^\s#]+)\s*(?:#.*)?/g while<>

  # 52
  -n $\=$/;$,=':';print/("[^"]*"|[^\s#]+)\s*(?:#.*)?/g


-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.

Reply via email to