On 01/04/2011 13:57, Rob Dixon wrote: > > use strict; > use warnings; > > my $data; > { > local $/; > $data =<DATA>; > } > > my $key = qr/ (?: \w+ [ ] )* \w+ /x; > > my @xx = $data =~ /\G ( $key ) \s? : \s* (.+?) \s* (?= $key \s? : | \z)/sgx;
My apologies, I had thought that there was always exactly one space between the end of the key and the colon. In fact the field 'PM NODE NUMBER' differs from all the others. The fix is to change this line to my @xx = $data =~ /\G ( $key ) \s* : \s* (.+?) \s* (?= $key \s* : | \z)/sgx; > > while (@xx) { > my ($key, $val) = splice @xx, 0, 2; > printf "%s=%s\n", $key, $val; > } Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/