# I have a hash of usernames %postiniList. # I have another hash of usernames %ldapList. # I have a text file in the working dir called # users.txt which contains one line per email # address with other unnecessary crap also. # We are traversing %postiniList to see if each key exists # in %ldapList and take action if it does NOT. foreach (keys %postiniList) { if(exists $ldapList{$_}) { print "$_ exists in ldap\n"; next; } else { print "$_ does not exist in ldap\n"; my $emailString = `cat users.txt |grep $_`; # these next three lines are messing it all up! if($emailString =~ /(\w+\@\w+\.\w+)/) { print "deleteuser $1\n"; } } }