in reply to Re^2: grep trouble
in thread grep trouble

> I'm still not sure what you're trying to achieve here, cause your grep returns the PATTERNs which matched.

Yes, LanX, and in scalar context it returns the NUMBER of patterns that matched. That's what I'm using in my (much larger) script.

> ...His input list to grep probably consists of a lot of patterns, which may include an empty string. ... where he showed us a literal empty string, there's probably a foreach loop with an iterator on the lefthand side of the match operator...

That's exactly what I'm doing, davido.

Obviously, if I posted a (much larger) block of real-life code here, it would make more sense (to those who bother comprehending it), but there would be much fewer interested people. A short, distilled version of the problem may not make real-life sense, but is much easier to discuss.

Replies are listed 'Best First'.
Re^4: grep trouble
by davido (Cardinal) on Apr 19, 2011 at 04:11 UTC

    That's the right strategy; post a minimal snippet that still demonstrates the problem. May have helped the curious if the original question mentioned 'this is a boiled down snippet' or something like that. Even though it's absolutely what people should be doing, the reality is that way too often we see some completely irrelevant code, or an entire script with no attempt to isolate the problem. Your post was great, and it motivated me to dig into the Perl docs. Any post that intrigues me enough to dig into the documentation again deserves a ++.


    Dave