You might try something more like this:
if ($line =~ /^\s*public(*.);\s*$/) { # do something }
The use of anchors (^ and $) at the beginning and end of your pattern will ensure that nothing (except some optional space characters) will appear before the 'public' or after the ';'. You may be able to adapt this to your needs.
In reply to Re: avoiding a particular character or set of characters
by ptum
in thread avoiding a particular character or set of characters
by neeha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |