http://qs321.pair.com?node_id=654950

dextius has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to understand two snippets of code, that have different behaviors that I do not immediately grasp. Consider:
use strict; use Data::Dumper; my @res = grep $_ split(",", "a,b,c,d,,f,,h"); print Dumper(\@res); my @res2 = grep { $_ } split(",", "a,b,c,d,,f,,h"); print Dumper(\@res2);
When ran, it returns
$VAR1 = [ 'a', 'c' ]; $VAR1 = [ 'a', 'b', 'c', 'd', 'f', 'h' ];
I understand the second example, as I am evaluating the "truth" of the elements I am iterating over. I do not understand the output of the first dump, when given just "$_". I did look at grep's perldoc, hoping for an ounce of clairvoyance, but to no avail.