while () { if (/(\w*) (\d*)/) { $hash1{$1} = $2; } else { warn "Invalid input line $.: $_\n"; } }