Perl has a C like syntax designed for computers, not humans - hence this sort of coding error gets made even by the best programmers.
In the for statement, the first part is the initialize, then the comparison, then the increment. So the error was to have two comparsions using ==.
I prefer languages where the = sign means assign or compare and the context of the statement will determine it automatically.