open(FILE,"test.txt"); my %inp = (); while(){ if(/^(.+?)\s+(\S+)/){ $inp{$1} = $2 } } close(FILE);