Welcome to the Monastery | |
PerlMonks |
Re^2: extracting the key value pairs from a stringby johngg (Canon) |
on Jun 27, 2008 at 08:56 UTC ( [id://694341]=note: print w/replies, xml ) | Need Help?? |
split /[^:]\s+/, $s That's not going to do what you hoped as it will consume the last character of each value except the one at the end of the string. You can get around that by using a negative look-behind. I also use map to avoid the for loop and temporary variables.
This produces
I hope this is of interest. Cheers, JohnGG
In Section
Seekers of Perl Wisdom
|
|