in reply to Need help with nested for loops

Not sure what your problem¹ is, but if you want a consecutive count try $j++ .

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)

¹) from How (not) to ask a question Include Sample Data (I/O)