my $s = ' ABC: 123 xyz: 100 def: YYY aaa: ZZZ'; my %hash; for (split /[^:]\s+/, $s) { my ($key, $val) = split /:\s*/; next unless $key; $hash{$key} = $val; }
In reply to Re: extracting the key value pairs from a string
by philipbailey
in thread extracting the key value pairs from a string
by mnranjeeth
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |