while () { chomp; if ( /^(.*),([^,]*)$/ ) { $hash{$1} = looks_like_number($2) ? $2 : 1 } else { $hash{$_} = 1 } }