my $file = "file"; my $temp = "temp"; foreach my $end (1..5) { open $file, '>', "$temp" . "$end"; print $file "THIS IS DATA"; }