And, as c0ncrete demonstrated above, Perl will happily tell you where the syntax errors are, you just need to use it.
Code:
C:\Temp>perl -c t.pl
syntax error at t.pl line 12, near "else"
syntax error at t.pl line 23, near "}"
t.pl had compilation errors.