Yikes. 5 hours! In the interest of saving you the hassle next time, might I recommend perltidy? The perltidy documentation shows how it helps find mis-matched braces at:
An example of finding a nesting error (here it is in
googles cache since the above link isn't working for me at the moment.)
-Blake