use strict; use warnings; # the simple case, as requested my $rain = int rand 2; my %rain_map = ( 0 => 'dry', 1 => 'wet', ); my %Weather = ( precipitation => $rain_map{$rain} ); print "Simple weather($rain) is $Weather{precipitation}\n"; # a little more my $precip = int rand 5; my %precip_map = ( 0 => 'dry', 1 => 'wet fog', 2 => 'wet rain', 3 => 'wet hail', 4 => 'plague of locusts', ); my %More_Weather = ( precipitation => $precip_map{$precip} ); print "More weather($precip) is $More_Weather{precipitation}\n";