sschneid has asked for the wisdom of the Perl Monks concerning the following question:
This is useful because it organizes the data based on DNs:my $data = $self->{'ldap'}->fetch( source => $self->{'config'}->{'ldap.base'}, filter => "cn=$self->{'arg'}->{'host'}" );
...and so on. The problem is, I am using this method to (occasionally) return only one DN. At the moment, I'm using the following code to transform $data so that it does not contain the DN key:$data = { 'cn=hostA,ou=Hosts,dc=company,dc=com' = { cn => 'hostA', ipAddress => '192.168.0.1', }, 'cn=hostB,ou=Hosts,dc=company,dc=com' = { cn => 'hostB', ipAddress => '192.168.0.2', } }
But I can only imagine that there must be a better way. Is there? The catch is to assume that the key (DN) is not known in advance.map { $data = $data->{$_}; } keys %{$data};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Transforming hash (removing useless key)
by friedo (Prior) on Jan 28, 2005 at 19:38 UTC | |
|
Re: Transforming hash (removing useless key)
by bgreenlee (Friar) on Jan 28, 2005 at 20:18 UTC | |
by nobull (Friar) on Jan 29, 2005 at 09:59 UTC | |
|
Re: Transforming hash (removing useless key)
by olivierp (Hermit) on Jan 28, 2005 at 21:12 UTC |