Huh?
I just read this post. Then I read it again, 10 times or so. I still can't understand what you're trying to accomplish...
Examples? Pseudo-code? I'll code it if you give me the basic algorithm. Or at least what you want accomplished, and exceptions to look for. Maybe some data to test my code on.
Or do you just want help in coding this? Or did you really mean to post this in the shell section? Because your little code looks like a bash script.
Anyways, just clearify what you need help on.
