my $str="cn=portal.090710.191533.428571000,cn=groups, dc=mp, dc=rj,dc=gov,dc=br";
if($str=~/cn=(.*),cn=/)
{
print $1;
}