sumeetgrover has asked for the wisdom of the Perl Monks concerning the following question:
Hi guys,
I need to carry out a calculation (an increment operation within a variable) through a regular expression.
That is, everytime, a specific pattern matches, I would like to increment a counter variable.
I am imagining, the code to be something like:
$data=~/<BEGIN_FLAG>/$flag_count++/ ....
So every time the regexp encounters <BEGIN_FLAG>, it increments the $flag_count variable.
Any help would be much appreciated.
Thank you!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Calculations in Regexp
by kennethk (Abbot) on Jan 20, 2011 at 14:35 UTC | |
|
Re: Calculations in Regexp
by toolic (Bishop) on Jan 20, 2011 at 14:35 UTC | |
|
Re: Calculations in Regexp
by Anonymous Monk on Jan 20, 2011 at 14:36 UTC | |
|
Re: Calculations in Regexp
by jethro (Monsignor) on Jan 20, 2011 at 14:42 UTC | |
by sumeetgrover (Monk) on Jan 20, 2011 at 15:04 UTC | |
by jethro (Monsignor) on Jan 20, 2011 at 16:49 UTC | |
by locked_user sundialsvc4 (Abbot) on Jan 20, 2011 at 15:19 UTC | |
|
Re: Calculations in Regexp
by happy.barney (Friar) on Jan 20, 2011 at 15:05 UTC |