parsing question

Jeff Zucker jeff at vpservices.com
Thu Mar 22 14:28:34 CST 2001


mikeraz at patch.com wrote:
> 
> I'm parsing a web form generated data set that looks like:
> 
> name:   data
> fname:  data
> time3:30-6:00:  data
> morestuff:
> gunk-o-rama:    data
> 
> The colons are followed by spaces or end of line, never tabs.
> 
> I thought that
>         ($fieldname, $data) = split /: */;
> would do the trick, but that ended up splitting the time entry at the first
> colon.

split /: */ means split on a colon /:/ folowed by zero or more spaces /
*/ which comes down to meaning split on any colon.

It's a bit hard to tell what you want the time field to be, but I assume
that "time3:30-6:00" is the name of the field.  If so, then this should
work:

    ($fieldname,$data) = split /:\s+/;

-- 
Jeff
TIMTOWTDI



More information about the Pdx-pm-list mailing list