in reply to Re^2: Why does this "bad" grep work so well?
in thread Why does this "bad" grep work so well?

in the case where the substitution fails (because the element contains no comma characters).

Yes. That's probably the reason for the hash constructor. If you replace it with an anonymous array constructor, it still works and the warning goes away.

my $i=0; my $line2 = join '', grep{ $i++ % 2 ? [ s/,/ /g ] : 1 } split /"/,$li +ne;

Ie. An array containing 0 or 1 is still true.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: Why does this "bad" grep work so well?
by AnomalousMonk (Archbishop) on Apr 16, 2016 at 07:17 UTC
    An array containing 0 or 1 is still true.

    And an array (or hash) reference is always true even if the referent is empty.


    Give a man a fish:  <%-{-{-{-<