in reply to Re: Unable to Understand grep and hash use for prime no.
in thread Unable to Understand grep and hash use for prime no.

... used or instead of an if-statement because, when using grep, he had to.

No, s/he didn't "have" to.

print "$_\n" for grep { if ($_%2) {$a=1} else {$a=0} $a } 1..10;

Yes, it's uglier, but possible.