Have put together a skeleton of a Region matching library in Perl. Idea was triggered from the log analysis script that I was writing last week. That worked pretty well, except for the fact that my fiance wanted to do other little bits with some other regions of the same file.
And then I got thinking and realized that 90% of the time I am trying to match text delimited by some patterns and trying to do something with the text in between – for instance, add log statements at start and end of function calls in a VB.NET source, clean up objects at end of function etc etc.
public function f
public function g
Also, being able to string two (or more) filters one behind the
other was another must have feature. i.e., filtered output of the first becomes input for the second.
And being able to negate a filter would be of added use – I guess it’ll just ease up stuff syntactically.
So I’ve been spending quite some time in the past two days and have finally the app code looks simple as I’d wanted…
my ($filter1, $filter2, $andfilter);
sub onMatchBegin; #app code callback
sub onMatchEnd; #app code callback
$| = 1;
$filter1 = new TextRegion::StartEndFilter('^\w+:\d+>\s*sysbuf', '^\**DONE\**ERRORBUF');
$filter2 = new TextRegion::StartFilter('^SWER');
$andfilter = new TextRegion::AndFilter($filter1, $filter2);
Am I on top of the world today!!! 😀 :D. Actually, the fun part of
programming is that spark of an idea that you can build and give a tangible shape – always beats me how people can’t not like programming.