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.
|
|---|
| 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 |