http://qs1969.pair.com?node_id=1079939


in reply to conditional statements in list constructors

If you want to conditionally include things in a list, try the x!! operator combo:

my $pi = 0; my $life = 'isgood'; my $foo = 1; my $aref = [ (3,1,4) x !!($pi), (42) x !!($life), ('bar', 'baz') x !!( +$foo) ]; print Dumper $aref;
gives:
$VAR1 = [ 42, 'bar', 'baz' ];