in reply to How do I get only one item out of attribute?
The easiest way is to use a regular expression.
You could also create a hash of the tokens like this if you need to test other values:my $dn = 'corpid=xxxxxx,ou=people,o=corp'; my ($ou) = $dn =~ /ou=([^,]*)/; print "ou = $ou\n";
This approach first splits the $dn variable into pairs of this form:my $dn = 'corpid=xxxxxx,ou=people,o=corp'; my %tokens = map {split /=/} split /,/, $dn; print "ou = $tokens{ou}\n";
corpid=xxxxxx ou=people o=corpIt then splits each of those pairs by the '=', which results in this list:
corpid, xxxxxx, ou, people, o, corpWhich is equivalent to defining a hash like this:
my %tokens = ( corpid => 'xxxxxx', ou => 'people', o => 'corp', );
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How do I get only one item out of attribute?
by izut (Chaplain) on Aug 21, 2006 at 17:18 UTC |
In Section
Seekers of Perl Wisdom