Fix loop for Perl 5.18