my $s = ' ABC: 123 xyz: 100 def: YYY aaa: ZZZ';; my %hash = $s =~ m[(\S+)\s*:\s*(\S+)]g;; print %hash;; ABC 123 def YYY aaa ZZZ xyz 100