my $t = 1; print grep {$t} qw( a b c d e ); What do you think that means? this is the same as: grep{1}qw( a b c d e ); and yields the exact same output as input list (a b c d e) grep {0} qw( a b c d e ); yields nothing! because this means foreach(a b c d e), pass each item to the output (to the left) if the thing within grep{} is true. BUT {0} is NOT true! So nothing is passed to your print. my $True_false = "False"; foreach (qw ( a b c d e )) { print if ($True_false eq "True"); print "" && $_; #another way #either way prints nothing!!! } Your very cute use of XOR is well, cute. my $t = 1; print grep {$t^=1} qw( a b c d e );