rgadireddy has asked for the wisdom of the Perl Monks concerning the following question:
i am sorry if some has already posted this. why grep behaves differently , when we use expression and using the output of the expression directly in the place of expression
my $t = 1; print grep {$t^=1} qw( a b c d e );
and using 0 directly instead using expression $t^=1 below
my $t = 1; print grep {0} qw( a b c d e ); my $t = 1; print grep {$t} qw( a b c d e );
20090717 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: grep function usage
by cdarke (Prior) on Jul 13, 2009 at 13:35 UTC | |
|
Re: grep function usage
by moritz (Cardinal) on Jul 13, 2009 at 12:55 UTC | |
|
Re: grep function usage
by Marshall (Canon) on Jul 13, 2009 at 13:56 UTC |