You need a non-greedy match:
if ($test =~ "LDAP://CN=(.*?),") { [download]
(note the question mark)
In reply to Re: Newbie Regex Problem by almut in thread Newbie Regex Problem by Anonymous Monk