in reply to grep of readline matching more lines than elements in array

I can only guess that the grep is matching more than one line for some of the elements in @isos20

Why are you guessing? Don't you know? If you don't even know if the problem exists, how can we help you?

And if the problem does exist, the way to verify it is to check the data, which we don't have.

I don't know why that would happen

There are two possibilities (assuming your actual code is correct. How can you "lose" a pair of //s when copy&pasting? You didn't C&P? Why not?):

  1. The file contains more than one line with the same identifier.

    You are not anchoring your regex to the the start of the line. Is it possible for a different identifier to appear someplace other than the beginning of the line?

  2. The array contains two or more copies of the same identifier.

    Have you checked the contents of the array?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re: grep of readline matching more lines than elements in array

Replies are listed 'Best First'.
Re^2: grep of readline matching more lines than elements in array
by AnomalousMonk (Archbishop) on Dec 03, 2013 at 20:02 UTC
    1.The [input] file contains more than one line with the same identifier.

    This seems to me the only way to obtain the results suggested in the OP. If there were multiple matches of a sub-string from an input file with the contents of the  @isos20 array, I would still expect the input file line to be output only once: grep in a "boolean" context would return true for one or more matches. (Update: I overlooked the fact that Laurent_R had already made essentially the same point here.)

    bdorsey: Is there perhaps some further constraint on the content of the input file that you have neglected to mention?