my $rain = 1; my %Weather = ( 'precipitation' => ($rain == 0) ? 'dry' : 'wet', ); #### my $rain = 1; my %Weather = ( 'precipitation' => $rain ? 'wet' : 'dry', ); #### my $precipitation; if ($rain == 0) { $precipitation = 'dry'; } elsif ($rain == 1) { $precipitation = 'wet'; }