note
imp
The easiest way is to use a regular expression.
<code>
my $dn = 'corpid=xxxxxx,ou=people,o=corp';
my ($ou) = $dn =~ /ou=([^,]*)/;
print "ou = $ou\n";
</code>
You could also create a hash of the tokens like this if you need to test other values:
<code>
my $dn = 'corpid=xxxxxx,ou=people,o=corp';
my %tokens = map {split /=/} split /,/, $dn;
print "ou = $tokens{ou}\n";
</code>
This approach first splits the $dn variable into pairs of this form:
<pre>
corpid=xxxxxx
ou=people
o=corp
</pre>
It then splits each of those pairs by the '=', which results in this list:
<pre>
corpid,
xxxxxx,
ou,
people,
o,
corp
</pre>
Which is equivalent to defining a hash like this:
<code>
my %tokens = (
corpid => 'xxxxxx',
ou => 'people',
o => 'corp',
);
</code>
568591
568591