$strings='toDNExtension:1111, toDNFailure:1111,'; foreach (split/,\s*/,$strings) { $hash{(split/:/,$_)[0]} = (split/:/,$_)[1]; }
is this useful? On Fri, 2 Sep 2005 09:41:54 -0400 (EDT), "Tom Allison" <[EMAIL PROTECTED]> said: > > I have a really long string that looks like > 'toDNExtension:1111, toDNFailure:1111, ' > > and I want to parse it into key/value pairs... > > I tried: > > foreach ( $string =~ /([\w\s]+):([\w\s]+)/g ) { > ... > } > > But I always get only the last pair... I thought the /g would stop that > behaviour.. > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > -- Jeff Pan [EMAIL PROTECTED] -- http://www.fastmail.fm - Faster than the air-speed velocity of an unladen european swallow -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>