$filesenders = "z:/train/whitesenders.txt"; $fileaddrlist = "z:/Program Files/Mailsweeper for SMTP/Config/shared/addrlist.test"; #Read and arrayify list of SMTP addresses open SENDERSREAD, $filesenders or die "unable to open sender file" ; foreach $newsender () { chomp $newsender; push @senders, $newsender; } #Open MailSweeper Addrlist.cfg and pull address lists into a hash of arrays open (CONFIGREAD, "<:utf8", $fileaddrlist) or die "UNable to open config file for read"; print "Reading Config File...\n"; foreach () { chomp; if (/\[(.*)\]/) { $currhead = $1; print "$currhead\n"; next; } next if (!(/./)); #Check for and omit blank lines push @{$config{$currhead}}, $_; } close CONFIGREAD; #Put senders captured from file into appropriate list foreach (@senders) { push @{$config{'AddressList\Scripted Whitelist'}}, "v:Member=\$S\"$_\""; } #write updated config to file, overwriting existing file open (CONFIGWRITE, ">:encoding(UTF-8)", $fileaddrlist) or die "unable to open config file for write"; foreach (keys %config) { print CONFIGWRITE "[$_]\n"; foreach (@{$config{$_}}) { print CONFIGWRITE $_; print CONFIGWRITE "\n"; } print CONFIGWRITE "\n"; } close CONFIGWRITE;