use warnings; #Read Security Engineering Inventory CSV Export and puke @ failure my $file = 'C:/perl64/seceng.csv'; my $hostpath = 'C:/perl64/nagios/hosts/'; #my $hostpath = '/usr/local/nagios/etc/objects/hosts/'; open (F, $file) || die ("Could not open $file!"); while () { @fields = split(',', $_); $hostname = $fields[3]; $hostip = $fields[5]; if(-e "$hostip"){ open (HOST, 'C:/perl64/nagios/hosts/' . $hostname) || die "Couldn't open: $!"; printf HOST "define host\{"; printf HOST "use linux-server;\n"; printf HOST "host_name $host;\n"; printf HOST "alias $host;\n"; printf HOST "address $hostip;\n"; printf HOST "\}"; } } close F;