Incrementing the count at the top of the loop is slightly cleaner:
my $size = 2;
my $i = 0;
while (@array) {
++$i;
open my $out, '>', "$i.txt" or die $!;
say {$out} $_ for splice @array, 0, $size;
}
say "$i files created.";
The point here is not optimisation, but to ensure $i has the right value wherever it is used. For a short piece of code like this the difference is not much, but add a few conditionals inside the loop and suddenly the semantics for $i can become rather uncertain.
Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond