S
spydox
I often find that I need to make a change to a block with logic like:
IN ALL START APPLE..END APPLE blocks, change NUMBER N to NUMBER N+1 if
the color is RED
Using a regex to do this seems impractical to me ( and perhaps it
really is), so in these WORD-ish cases I usually just loop through the
array lines and set flags like $inAPPLE++... Its also tricky because
often as in this case, I have to *look ahead* to check the color.
Which makes looping not so nifty either.
What I'd really prefer is a regex that sensed when I was in a START
APPLE..END APPLE clause (of course ONLY in one clause- not the very
FIRST START APPLE to the very LAST END APPLE), then
Another approach I sometimes take is to split() the blocks out, then
map the regex into the split array, then recombine. That's actually
usually pretty effective, but sort of a pain because I have to
scalarize the array, split it, map it, recombine it, and then re-array
it. Geesh!
So anyhow- I'm just wondering if this is some sort of perfunc or regex
etc I can use to assist? I feel like I'm barking up the wrong tree..
Thanks in advance gurus..
!
START APPLE
..
..
NUMBER 5
COLOR RED
..
..
END APPLE
..
!
START ORANGE
..
..
NUMBER 10
COLOR GREEN
..
END ORANGE
..
..
!
START APPLE
..
..
NUMBER 10
COLOR GREEN
..
..
END APPLE
!
START APPLE
..
..
NUMBER 2
COLOR RED
..
..
END APPLE
IN ALL START APPLE..END APPLE blocks, change NUMBER N to NUMBER N+1 if
the color is RED
Using a regex to do this seems impractical to me ( and perhaps it
really is), so in these WORD-ish cases I usually just loop through the
array lines and set flags like $inAPPLE++... Its also tricky because
often as in this case, I have to *look ahead* to check the color.
Which makes looping not so nifty either.
What I'd really prefer is a regex that sensed when I was in a START
APPLE..END APPLE clause (of course ONLY in one clause- not the very
FIRST START APPLE to the very LAST END APPLE), then
Another approach I sometimes take is to split() the blocks out, then
map the regex into the split array, then recombine. That's actually
usually pretty effective, but sort of a pain because I have to
scalarize the array, split it, map it, recombine it, and then re-array
it. Geesh!
So anyhow- I'm just wondering if this is some sort of perfunc or regex
etc I can use to assist? I feel like I'm barking up the wrong tree..
Thanks in advance gurus..
!
START APPLE
..
..
NUMBER 5
COLOR RED
..
..
END APPLE
..
!
START ORANGE
..
..
NUMBER 10
COLOR GREEN
..
END ORANGE
..
..
!
START APPLE
..
..
NUMBER 10
COLOR GREEN
..
..
END APPLE
!
START APPLE
..
..
NUMBER 2
COLOR RED
..
..
END APPLE