After reviewing this thread for the 100th time I figured out what my issue was. In the first reply archon states your not comping your $mac, boy was he ever right. This was fixed by throwing a chomp $mac into my for each loop before the sub routine ldapsearch() is called. Thanks again for everyones help. Atleast now my code is a little more refined and works !