in reply to extracting the key value pairs from a string
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: extracting the key value pairs from a string
by johngg (Canon) on Jun 27, 2008 at 08:56 UTC |