in reply to Grep failing

grep is usually used to sift through an array or list. You're passing it a scalar variable, not a list. That's one problem. What do you think $mk contains?

grep in scalar context will return a count of how many matches it found in the list passed to it. So it would seem that whatever it is that $mk contains, it does NOT contain anything that matches with the expression, "/^\Q$folder\E$/". Since it doesn't match (not even once), the number of hits is zero, and that's what gets passed back from grep to $folder_present. grep isn't failing, as your post's title suggests. It's doing what it's designed to do.

What are you trying to accomplish? I don't mean what do you want this little snippet to do. I mean what is the bigger picture here? What is your goal?


Dave