in reply to minimising repetitive if-elsing

It depends on what changes for each run through the loop. If the "coords" param in your HTML stays the same for each respective postion, you could move its parameter into a second array, indexed by "$i + $some_num", where $some_num is what you're incrementing $i by in your if statement.

There really isn't enough information in your post to help you further.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated