my %args = (profile => 'foo'); my %ta = map {defined($args{$_} ? ($_ => $args{$_}) : ()} qw(profile user password);