http://www.perlmonks.org?node_id=1094576

james28909 has asked for the wisdom of the Perl Monks concerning the following question:

ok i originally answered my own question this time. i wanted to make any prespecified number of files with a foreach loop (or for loop, i dont think it matters much). I accomplished that with this code and didnt have to ask :
my $file = "file"; my $temp = "temp"; foreach (1..5){ open $file, '>', "$temp$_"; print $file "THIS IS DATA"; }

now my next question is, i have been reading around here and there about this special variable "$_" and come across this thread Here and it say to try to avoid this special variable. in the code above, it was my very first time to even try using it tbh, could someone explain to me why it should be avoided in the case of my code above? or is it ok? or what would be a better solution to it?