Why not just $flag_count++ if ($data=~/<BEGIN_FLAG>/); ?
if you expect more than one match in a single string, check out the 'g' modifier in perlop and what it does in scalar context
You could also use a substitution regex with ge modifier, but that sounds a bit like a hack, since you do no substitution
PS: Is this homework, the problem seems somewhat artifical?
In reply to Re: Calculations in Regexp
by jethro
in thread Calculations in Regexp
by sumeetgrover
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |