If you suspect a problem with the regex, the first thing I would do is get rid of the
g modifier. I'm not saying it will solve your problem, but it does seem out of place. Also, Tip #9 from the
Basic debugging checklist recommends using
YAPE::Regex::Explain to demystify regular expressions.
If you could re-create your problem with some self-contained code and data, it would be something we could run. As it stands, you are reading in multiple files which we do not have access to.
Here are some other things that look suspicious to me:
- You use your input lines as filenames without chomping them first.
- You are using $_ in different places inside nested while loops. It might be easier to use a different named, scoped variable for each loop.
Also, I recommend commenting out use diagnostics; when you are done debugging.