use strict; my %hash = (); while () { chomp; $hash{$1} = $2 if m/^(.*?)\s+(.*)$/; } print "$_ = $hash{$_}\n" for keys %hash; __DATA__ EVENT_LOG_EMITTER rtbd:service=EventEmitterService,name=EventLogEmitter,protocol=XML EVENT_LOG_EMITTER2 rtbd:service=EventEmitterService,name=EventLogEmitter,protocol=XML2