I am using strict and warnings. It is somewhat indented correctly, it's a subroutine, and I'm still working on it, so the extra lines will be cleaned up.. I don't see a syntax error, unless you're talking about the extra curly brace at bottom, which is just the closing of the sub, I didn't get the sub name in copy/paste.
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man.." -- George Bernard Shaw