# set $value to the value held in the array position we're on my $value = $myArr[$i]; # set $index to one more than our current array position my $index = $i + 1; #create our filename - when i = 0, it will be "file1" my $file = "file${index}"; write_value_to_file($value, $file); # call our function below with our current value and filename } # end the for block