in reply to Re: Whats wrong in this code?
in thread Whats wrong in this code?

I can imagine how to use tr/// instead of m//, but how do you want to replace grep with tr?

($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Replies are listed 'Best First'.
Re^3: Whats wrong in this code?
by Laurent_R (Canon) on Nov 18, 2016 at 13:45 UTC
    tr/// returns the number of substitutions made, i.e. 0 (or false) if the searched character wasn't found, and something true otherwise. So it could more or less work to replace a grep in the specific use of grep in the original post, but you can't use a regex to specify that the ">" character should be at the beginning of the line.
      But you can apply tr/// only to a string, but grep applies to a list.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
        Yes, you're right, I spoke too quickly. tr/// can possibly replace the regex within the grep block, but can't replace grep itself.