use strict; use warnings; my %h = ('a'=>'123','b'=>'xxx','c'=>''); my %newhash; for(keys %h){ $newhash{$_} = $h{$_} if $h{$_} ne '' }; print join(",", keys %newhash)."\n";