I'm afraid the regexp that'd match the whole file would be too long and messy. And testing each line separately whether its something unexpected is not good enough, I need to test the lines in context.
But I like this config file with patterns and state changes idea. I think I'll use something like
(
START => {
'^FileCreate \d+\.\d+.\d+$' => 'START',
'^---- Ticking: \d{4}/\d\d/\d\d \d\d:\d\d:\d\d - \d\d:\d\d:\d\
+d$' => 'START',
'^Creating files for site ' => 'FILES'
},
FILES => {
'^\tCreating file ' => 'FILE',
'^File generation succeeded for site ' => 'START',
'^File generation failed for site ' => '--ERROR--',
'^Jobs for site \d+ with parameter type "\w+" are to be proces
+sed by HTTPPost or something.' => 'FILES',
'^Site \d+ has posting parameters either only for single or fo
+r package jobs!!!' => 'FILES',
},
...
)
or maybe(
START => [
qr'^FileCreate \d+\.\d+.\d+$' => 'START',
qr'^---- Ticking: \d{4}/\d\d/\d\d \d\d:\d\d:\d\d - \d\d:\d\d:\
+d\d$' => 'START',
qr'^Creating files for site ' => 'FILES'
],
FILES => [
qr'^\tCreating file ' => 'FILE',
qr'^File generation succeeded for site ' => 'START',
qr'^File generation failed for site ' => '--ERROR--',
qr'^Jobs for site \d+ with parameter type "\w+" are to be proc
+essed by HTTPPost or something.' => 'FILES',
qr'^Site \d+ has posting parameters either only for single or
+for package jobs!!!' => 'FILES',
],
...
)
and read it with do() or eval().
The second has two advantages. The regexps will be precompiled and they will be tested in a dependable order. But the code will look a little awkward.
Thanks for your ideas, Jenda |