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;