On Thu, 16 May 2013 21:57:55 +0200, Natxo Asenjo wrote:
>in a ldap script where I get a list of values of a multivalued >attribute like this:
>@memberof = qw( cn=group1,cn=xxx,dc=domain,dc=tld >cn=group2,cn=xxx,d=domain,dc=tld etc etc) ;
>I would like to use map to convert the list of elements to
>@memberof = qw( group1 group2 group3 etc etc )
I'm not clear on what you are trying to achieve. Your problem is probably in the RE. The comma in your RE is greedy.
A "?" within the brackets makes it non greedy. Read
for a good explanation of this subject.
The code below illustrates the difference.
#!/usr/bin/perl -w
use 5.14.0;
my $str = "cn=group1,cn=xxx,dc=domain,dc=tld cn=group2,cn=xxx,d=domain,dc=tld";
$str =~ /^cn=(.*),.*/;
say $1;
$str =~ /^cn=(.*?),.*/;
say $1;
__END__
*** Output ***
group1,cn=xxx,dc=domain,dc=tld cn=group2,cn=xxx,d=domain
group1
--
Peter Gordon, pete...@netspace.net.au on 05/17/2013
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/