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