* is greedy, which means it will match the longest substring it can. You can force * to be non-greedy by following it with ?
if ($test =~ m{LDAP://CN=(.*?),}) {
You'll also note I've taken out the last .*, as it serves no purpose and changed your string to a regexp.
See perlre and perlretut for more information.
In reply to Re: Newbie Regex Problem
by FunkyMonk
in thread Newbie Regex Problem
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |