Hi Monks! I am having a prob with matching characters for a part of a counter script. The purpose of this part of the script is to count how many times the $constant variable (provided upon execution) appears in the file. The problem is occurring when the $constant varible is a special variable $, $$, ##, @@, etc. I have to assume that the $constant can be anything under the sun as this is a generic script, but with my code below I am not able to accomplish that. Any help would be greatly appreciated. Thanks!
$constant = '$$'; $line_count =0; while (<FILE>){ if($constant ne "") { if($_ =~ m/^($constant)/) { $line_count++; } } }
In reply to Issue with regex matching by sowais
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |