natxo has asked for the wisdom of the Perl Monks concerning the following question:
So I want to substitute the regex "dc=domain,dc=tld" by "dc=sub,dc=otherdomain,dc=tld". I get a list of 1s .... (so 1, 1, 1, ...). Any help greatly appreciated.my $array_ref = [ "cn=a,dc=domain,dc=tld", "cn=b,dc=domain,dc=tld", "cn=c,dc=domain,dc=tld", "cn=d,dc=domain,dc=tld", "cn=e,dc=domain,dc=tld", "cn=f,dc=domain,dc=tld", "cn=g,dc=domain,dc=tld", "cn=h,dc=domain,dc=tld", "cn=i,dc=domain,dc=tld", "cn=j,dc=domain,dc=tld", "cn=k,dc=domain,dc=tld", "cn=m,dc=domain,dc=tld", "cn=n,dc=domain,dc=tld", "cn=o,dc=domain,dc=tld", "cn=l,dc=domain,dc=tld", ]; my @values = map { s/dc=domain,dc=tld/dc=sub,dc=otherdomain,dc=tld/i; +$_ } @$array_ref; print $_, "\n" for @values;
Edit: solved, added $_ at the end of the regex.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: map on array reference
by 1nickt (Canon) on Feb 15, 2016 at 19:35 UTC | |
|
Re: Solved: map on array reference
by kcott (Archbishop) on Feb 16, 2016 at 09:55 UTC |