foreach my $cur_ip (@ips) #or perhaps $this_ip or other name? { $record[7]=$cur_ip; $csv->print ($cur_ip, \@record); }