my %lookup; foreach my $alpha ('a'..'k') { foreach my $numb (0..9) { $_ = $alpha . $numb; $lookup{$_} = /^g[6-9]$/ ? 1 : /^[gk][0-5]$/ ? .5 : 0; } }