$res =~ /^([^:]+):\ {0,1}([^\ ].*)$/;
$key = $1 if ($1);
$val = $2 if ($2);
should be
$res =~ /^([^:]+):\ {0,1}([^\ ].*)$/;
$key = $1 if (defined $1);
$val = $2 if (defined $2);
otherwise values like Key: 0 will
be discarded.
ty.