for (my $i = 0; $i < $a; $i++) { rename $oldfiles[$i],$newfiles[$i]; }