
fhare
New User
Jul 21, 2008, 1:49 PM
Post #1 of 2
(2112 views)
|
|
recursivly matching string (a filename) in file, then testing said filename for same string, etc, etc...
|
Can't Post
|
|
I have a need to parse a file for "jsp:include=filename.inc", strip the filename out of the above include, and test it's existence, and if it exists, parse THAT file for the jsp:include filename string, etc etc recursively until all the includes in this "include tree" have been found (could be many layers deep, but prob not more than 6-10). I'd also like to keep track of the parent to child relationship somehow, so I know which include came from which parent in the tree. I already have the regex for finding all the iterations of the jsp:include down, and for striping and cleaning the filename for further testing, but I am having trouble with the recursion through the tree of matches. I started this in bash but quickly realized I needed more than bash can give me, and I think Perl is probably the right tool, but I'm only so so with Perl. If anyone could help point me in the right direction for how to handle the recursion part, I'd appreciate it. I'm guessing some kind of hash would work.
|