perl -we 'my %new_hash; my %hash = (foo => "bar", rofl => undef); foreach (keys %hash) {$new_hash{$_} = $hash{$_} if defined $hash{$_}}; print %new_hash '