$line = 'key1,value1,key2,value2'; my %foo = split ',', $line; print $foo{key2}; #prints the value associated with key2, i.e. value2