$i was previously declared, I should have mentioned that. This is a snippet of the entire code.
Like I said, I only just learned Perl. I learned C last semester and the stuff I do at my work is a lot of string-manipulation stuff so that's why I switched.
I wrote the initial thing when I was still making the transition from C to Perl -- I'd basically write C code with Perl. I'm getting much better at coding Perl-style-Perl but it's been a month.
I also did not know I could hide specific warnings. Thanks.
The reason I mentioned $i is that you reuse the variable (not just the name). I typically view that as bad, especially when it's trivial to declare it for the loop itself.