split/Perl question
David A. Sinck
plug-discuss@lists.plug.phoenix.az.us
Mon, 11 Nov 2002 13:17:10 -0700
\_ SMTP quoth Mike Starke on 11/11/2002 15:16 as having spake thusly:
\_
\_ I have a colon delimited text file that I need parse thru and grab each value.
\_ My problem is that some values actually contain a colon. Using the code below
\_ is not quite enough to extract the values:
\_
\_ while (<>) {
\_ @array = split(":", "$_");
\_ }
\_
\_ I seem to recall this same problem before but can not remember
\_ what I did to get around this. Can anyone point me in the right
\_ direction?
Use a different delimiter? :-)
Unless your delimiter is somehow quoted OR your data format is
fixed-field-length, you could be in a world of hurt.
Split's third parameter is a limiter, which may be helpful if your
'dirty' data is in the last field.
There's a couple of possible solutions, depending on how many fields
have :-dirty data, but without samples, I'm not going to go into
whatifs. :-)
David