for (1..$num) { open my $fh, '>', sprintf "temp%02d",$_; # temp01, temp02, etc. ... }