my %hash = ( foo => 'bar', ); if ($quux) { $hash{baz} = $quux; }