I have been working on a script for a few days now and I'm just not getting the handle on it. One of the things I'm trying to do is read in a csv file that has a list of names in two columns like: "Johnson, Joe",Phyllis Ivy "Harris, Al",Maureen Murl "Farris, Allen",Sandra Norm "Daniels, Greg",Gwen Fair Next, I search AD and return their email addresses. Of course some them won't be found which is another problem I'm having. So since it returns some of the emails then the ones that it doesn't return it messes up the formatting. Also, what I want it to do is return the names of the people if an email address was not found. please let me know if anyone needs more information. below is the script that I am using currently: #!perl use Getopt::Long; use Net::LDAPS; use Text::CSV; ($domainCont, $surNm, $givenNm, $dispNm, $eNo, $outFlNm, $id, $pw) = ('', '', '','', -1, '', '', ''); &GetOptions('dc=s' => \$domainCont ,'i=s' => \$id ,'p=s' => \$pw ,'d=s' => \$baseDir ,'f=s' => \$inFlNm); my $ad = Net::LDAP->new($domainCont) or die "Can't connect to AD >$!<\n"; $ad->bind($id, password=>$pw) or die " bind for $id failed >$!<\n"; my $base = 'OU=People,OU=staff,DC=ad,DC=wjgilmore,DC=com'; my $attrs = "sn, givenname"; open IN, "<"."./$baseDir/$inFlNm" or die "Can't open transfers file >$inFlNm<\n"; $outFlNm = "test.csv"; open OUT, ">"."./$baseDir/$outFlNm" or die "Can't open transfers file >$outFlNm<\n"; while(){ @manager = split(/"/, $_); @assist = split(/ /, $manager[2]); chop($assist[1]); @assist2 = split(/,/, $assist[0]); $assistant = "$assist[1], $assist2[1]"; $filter1 = '(displayName='.$manager[1].')'; $filter2 = '(displayName='.$assistant.')'; my $results1 = $ad->search(base=>$base,filter=>$filter1,attrs=>$attrs); my $results2 = $ad->search(base=>$base,filter=>$filter2,attrs=>$attrs); #print "$filter1\n"; foreach $adEnt ($results1->entries){ my $entry1 = $results1->entry($i1); my $mail1 = $entry1->get_value('mail'); chomp; print OUT "$manager[1],"; print OUT "$mail1,"; #printf $entry1->get_value('mail')."\n"; } foreach $adEnt ($results2->entries){ my $entry2 = $results2->entry($i2); my $mail2 = $entry2->get_value('mail'); print OUT "$assistant,"; print OUT "$mail2,\n"; #printf $entry2->get_value('mail')."\n"; } } $ad->unbind;