On Tue, Jan 08, 2002 at 10:37:45AM -0800, Yitzchak Scott-Thoennes wrote:
> Here's a hole:
>
> 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 ':'.
Does this work?
-p s/\s*("([^"]*)"|((\S*?)#.*)|(\S+))\s*/$2$4$5:/g,s/:+$/\n/
Wesley.