I have a "search text" which i need to search in file. If that text is found in urls then variable j should be incremented and if its found somewhere else then variable k should be incremented.i tried if ($filecontent =~ m|<\s*a\s+[^>]*href\s*=\s*[\"'](.*?)$search_text(.*?)[\"'>]|gi) { print " if " ; $ j ++ ; }if ($filecontent !~ m|<\s*a\s+[^>]*href\s*=\s*[\"'](.*?)$search_text(.*?)[\"'>]|gi) { print " else "; $k ++ ; } but its printing both if and else and incrementing both j and k..