http://www.perlmonks.org?node_id=470381


in reply to Scalar joining, concatenation, involving varying text

I'd try something like this:

my %values = ( a => 1, b => 0, c => 1); my $combined = ''; foreach (sort keys %values) { $combined .= "$_=$values{$_} " if $values{$_}; }

Once you understand the above solution, you can try to replace it with using map and grep. Even though I'm very familiar with both, I'd just leave it like that, though.