use strict; use warnings; my $combined = ''; my ( $a, $b, $c ) = ( 1, 0, 1 ); eval qq(if ( \$$_ ) { \$combined .= "$_=\$$_ " }) for qw( a b c ); print "$combined\n"; __END__ a=1 c=1