while () # or wherever those lines come from { /^(\d+)\s+\d+,\s*(.*)/ and $hash{$1} = $2; }