1. You might want to use an alternative regex delimiter since you are matching on strings containing the default '/', although you imply that your code compiles, so maybe that's irrelevant in this case:

Code

if ($line =~ m|$_[0]|g ) ...

2. Of course m|/abc/pg| matches '/abc/pqrs', or anything else before or after. You'll have to make the pattern more specific to your data. Hints:

Code

# Constrain match to the end of the line. m|$_[0]$| # Constrain match to the end of the word. m|$_[0]\s+| # Constrain match to a trailing character delimiter, like another slash. m|$_[0]/|