in reply to syntax error

First off, advice on improving your script: start over! ;)

Here is your syntax error, you have a structure like so:

foreach (@stuff) { if ($boolean) { ... } } else { ... }
That is invalid code. At this point, your script is almost (but not necessarily) beyond repair. I suggest that you sit down, design what you want to accomplish, and then use HTML::Template - this module will allow you you to take the HTML out of your Perl script so you can focus on logic. It takes a little time to understand HTML::Template, but it is time well invested -- as is designing. I also recommend you take the time to indent your code properly. If you don't know how to do that, then download Perl Tidy and run your code through it. Without proper indention, you run into problems like you have above. A lot of newbies say "I'll go back and indent it later." This never happens. Indent as you code and avoid mistakes like you have above. Best of luck. :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)